class BettyResource::Model::Property

Attributes

id[R]
kind[R]
name[R]
options[R]

Public Class Methods

new(id, model_id, name, kind, options) click to toggle source
# File lib/betty_resource/model/property.rb, line 21
def initialize(id, model_id, name, kind, options)
  @id, @model_id, @name, @kind, @options = id, model_id, name, kind, options
  extend_kind_methods if %(belongs_to has_and_belongs_to_many has_many).include?(kind)
end
parse(model_id, input) click to toggle source
# File lib/betty_resource/model/property.rb, line 12
def self.parse(model_id, input)
  input.map do |row|
    options = row['options']
    inverse_association = row["inverse_association"]
    options.merge!("inverse_association" => inverse_association) if inverse_association
    Property.new(row['id'], model_id, row['name'], row['kind'], options)
  end
end

Public Instance Methods

collection?() click to toggle source
# File lib/betty_resource/model/property.rb, line 26
def collection?
  false
end
model() click to toggle source
# File lib/betty_resource/model/property.rb, line 34
def model
  @model ||= BettyResource.meta_data.models.values.find { |x| x.id == @model_id }
end
typecast(record, value) click to toggle source
# File lib/betty_resource/model/property.rb, line 30
def typecast(record, value)
  value
end