Class: Syphon::Schema::DSL
- Inherits:
-
Struct
- Object
- Struct
- Syphon::Schema::DSL
- Defined in:
- lib/syphon/schema.rb
Instance Method Summary collapse
- #_eval(&block) ⇒ Object
- #field(name, type, expression, options = {}) ⇒ Object
- #join(string = nil, &block) ⇒ Object
- #nested(name, options = {}, &block) ⇒ Object
Instance Method Details
#_eval(&block) ⇒ Object
126 127 128 129 130 131 132 133 |
# File 'lib/syphon/schema.rb', line 126 def _eval(&block) if block.arity == 1 block.call(self) else instance_eval(&block) end schema end |
#field(name, type, expression, options = {}) ⇒ Object
135 136 137 |
# File 'lib/syphon/schema.rb', line 135 def field(name, type, expression, = {}) schema.fields[name.to_sym] = Field.new(schema, name, type, expression, ) end |
#join(string = nil, &block) ⇒ Object
166 167 168 169 170 |
# File 'lib/syphon/schema.rb', line 166 def join(string = nil, &block) string && block and raise ArgumentError, "both string and block given" schema.joins << (string || block) end |
#nested(name, options = {}, &block) ⇒ Object
147 148 149 |
# File 'lib/syphon/schema.rb', line 147 def nested(name, = {}, &block) schema.fields[name.to_sym] = NestedField.new(schema, name, , &block) end |