Class: BettyResource::Model::Property
- Inherits:
-
Object
- Object
- BettyResource::Model::Property
- Includes:
- KindExtendable
- Defined in:
- lib/betty_resource/model/property.rb,
lib/betty_resource/model/property/types/has_many.rb,
lib/betty_resource/model/property/types/belongs_to.rb,
lib/betty_resource/model/property/types/association.rb,
lib/betty_resource/model/property/types/has_and_belongs_to_many.rb
Defined Under Namespace
Modules: Types
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #collection? ⇒ Boolean
-
#initialize(id, model_id, name, kind, options) ⇒ Property
constructor
A new instance of Property.
- #model ⇒ Object
- #typecast(record, value) ⇒ Object
Methods included from KindExtendable
Constructor Details
#initialize(id, model_id, name, kind, options) ⇒ Property
Returns a new instance of Property.
21 22 23 24 |
# File 'lib/betty_resource/model/property.rb', line 21 def initialize(id, model_id, name, kind, ) @id, @model_id, @name, @kind, @options = id, model_id, name, kind, extend_kind_methods if %(belongs_to has_and_belongs_to_many has_many).include?(kind) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/betty_resource/model/property.rb', line 10 def id @id end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
10 11 12 |
# File 'lib/betty_resource/model/property.rb', line 10 def kind @kind end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/betty_resource/model/property.rb', line 10 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/betty_resource/model/property.rb', line 10 def @options end |
Class Method Details
.parse(model_id, input) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/betty_resource/model/property.rb', line 12 def self.parse(model_id, input) input.map do |row| = row['options'] inverse_association = row["inverse_association"] .merge!("inverse_association" => inverse_association) if inverse_association Property.new(row['id'], model_id, row['name'], row['kind'], ) end end |
Instance Method Details
#collection? ⇒ Boolean
26 27 28 |
# File 'lib/betty_resource/model/property.rb', line 26 def collection? false end |
#model ⇒ Object
34 35 36 |
# File 'lib/betty_resource/model/property.rb', line 34 def model @model ||= BettyResource..models.values.find { |x| x.id == @model_id } end |
#typecast(record, value) ⇒ Object
30 31 32 |
# File 'lib/betty_resource/model/property.rb', line 30 def typecast(record, value) value end |