Class: QueryInterface::Client::Property
- Inherits:
-
Object
- Object
- QueryInterface::Client::Property
- Defined in:
- lib/query-interface-client/model.rb
Instance Attribute Summary collapse
-
#array ⇒ Object
Returns the value of attribute array.
-
#default ⇒ Object
Returns the value of attribute default.
-
#name ⇒ Object
Returns the value of attribute name.
-
#primary ⇒ Object
Returns the value of attribute primary.
-
#type ⇒ Object
Returns the value of attribute type.
-
#update ⇒ Object
Returns the value of attribute update.
Instance Method Summary collapse
-
#initialize(name, type, options = {}) ⇒ Property
constructor
A new instance of Property.
- #run_get_conversion(value) ⇒ Object
- #run_set_conversion(value) ⇒ Object
Constructor Details
#initialize(name, type, options = {}) ⇒ Property
Returns a new instance of Property.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/query-interface-client/model.rb', line 8 def initialize(name, type, ={}) unless conversion = QueryInterface::Client.types[type] raise "Unknown Type #{type}" end self.type = conversion self.primary = .delete(:primary) { false } self.update = .delete(:update) { true } self.array = .delete(:array) { false } self.default = .delete(:default) { lambda { nil } } end |
Instance Attribute Details
#array ⇒ Object
Returns the value of attribute array.
6 7 8 |
# File 'lib/query-interface-client/model.rb', line 6 def array @array end |
#default ⇒ Object
Returns the value of attribute default.
6 7 8 |
# File 'lib/query-interface-client/model.rb', line 6 def default @default end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/query-interface-client/model.rb', line 6 def name @name end |
#primary ⇒ Object
Returns the value of attribute primary.
6 7 8 |
# File 'lib/query-interface-client/model.rb', line 6 def primary @primary end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/query-interface-client/model.rb', line 6 def type @type end |
#update ⇒ Object
Returns the value of attribute update.
6 7 8 |
# File 'lib/query-interface-client/model.rb', line 6 def update @update end |
Instance Method Details
#run_get_conversion(value) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/query-interface-client/model.rb', line 19 def run_get_conversion(value) if self.array value ||= [] value.map { |item| self.type.apply_get(item) } else self.type.apply_get(value) unless value.nil? end end |
#run_set_conversion(value) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/query-interface-client/model.rb', line 28 def run_set_conversion(value) if self.array value ||= [] value.map { |item| self.type.apply_set(item) } else self.type.apply_set(value) unless value.nil? end end |