| Class | Ribs::Rib |
| In: |
lib/ribs/rib.rb
|
| Parent: | Object |
Contains the mapping data that gets created when calling the {Ribs!} method.
| METHODS_TO_LEAVE_ALONE | = | ['__id__', '__send__'] | These are the only methods left alone - this becomes a blank slate, mostly. |
Create all value parts
# File lib/ribs/rib.rb, line 53
53: def initialize
54: @columns = { }
55: @primary_keys = []
56: @to_avoid = []
57: @default_values = { }
58: end
Returns a reference object that allow access to the resulting data objects
# File lib/ribs/rib.rb, line 62
62: def __column_data__
63: ColumnData.new(@columns, @primary_keys, @to_avoid, @default_values)
64: end
Handles property names. The only ones that aren‘t possibly to use is "initialize", "column_data", "id", "method_missing" and "send". Everything else is kosher. … Maybe there should be a way of getting those last ones too…
If no arguments are supplied, will return a RibColumn
# File lib/ribs/rib.rb, line 73
73: def method_missing(name, *args, &block)
74: if args.empty?
75: RibColumn.new(name, @columns, @primary_keys, @to_avoid, @default_values)
76: else
77: hsh = args.grep(Hash).first || {}
78: args.grep(Symbol).each do |ss|
79: hsh[ss] = true
80: end
81:
82: hsh = {:column => name}.merge(hsh)
83:
84: if hsh[:primary_key]
85: @primary_keys << name.to_s
86: end
87:
88: if hsh[:avoid]
89: @to_avoid << name.to_s.downcase
90: if hsh[:default]
91: @default_values[name.to_s.downcase] = hsh[:default]
92: end
93: end
94:
95: @columns[name.to_s] = [hsh[:column].to_s, hsh]
96: nil
97: end
98: end