Class: Syphon::Schema::Field
- Inherits:
-
Object
- Object
- Syphon::Schema::Field
- Defined in:
- lib/syphon/schema.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(schema, name, type, expression, options = {}) ⇒ Field
constructor
A new instance of Field.
- #multi? ⇒ Boolean
- #select(outer = nil) ⇒ Object
Constructor Details
#initialize(schema, name, type, expression, options = {}) ⇒ Field
Returns a new instance of Field.
87 88 89 90 91 92 93 94 |
# File 'lib/syphon/schema.rb', line 87 def initialize(schema, name, type, expression, = {}) @schema = schema @name = name.to_sym @type = type @expression = expression @properties = .merge(type: type) @multi = [:multi] end |
Instance Attribute Details
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
96 97 98 |
# File 'lib/syphon/schema.rb', line 96 def expression @expression end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
96 97 98 |
# File 'lib/syphon/schema.rb', line 96 def name @name end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
96 97 98 |
# File 'lib/syphon/schema.rb', line 96 def properties @properties end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
96 97 98 |
# File 'lib/syphon/schema.rb', line 96 def schema @schema end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
96 97 98 |
# File 'lib/syphon/schema.rb', line 96 def type @type end |
Instance Method Details
#multi? ⇒ Boolean
98 99 100 |
# File 'lib/syphon/schema.rb', line 98 def multi? @multi end |
#select(outer = nil) ⇒ Object
102 103 104 105 |
# File 'lib/syphon/schema.rb', line 102 def select(outer = nil) name = outer ? "#{outer}[#{self.name}]" : self.name "#{schema.send(:query_fragment, expression)} AS `#{name}`" end |