Class: Rho::NewORMModel

Inherits:
Object show all
Defined in:
lib/framework/newrhom/newrhom_model.rb

Constant Summary collapse

MODEL_FIELDS =
['loaded', 'model_name', 'sync_type', 'sync_priority', 'partition', 'source_id', 'fixed_schema', 'freezed', 'associations']
LEGACY_FIELDS =
['name']

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/framework/newrhom/newrhom_model.rb', line 67

def [](key)
  result = nil
  key_s = key.kind_of?(String) ? key : key.to_s
  if LEGACY_FIELDS.include?(key_s)
    @legacy_field ||= {}
    @legacy_field[key_s]
  else
    raise "Missing field #{key_s}" unless MODEL_FIELDS.include?(key_s)
    self.send(key_s.to_sym)
  end
end

#[]=(key, value) ⇒ Object



79
80
81
82
83
84
85
86
87
88
# File 'lib/framework/newrhom/newrhom_model.rb', line 79

def []=(key, value)
  key_s = key.kind_of?(String) ? key : key.to_s
  if LEGACY_FIELDS.include?(key_s)
    @legacy_field ||= {}
    @legacy_field[key_s] = value
  else
    raise "Missing field #{key_s}" unless MODEL_FIELDS.include?(key_s)
    self.send((key_s+'=').to_sym, value)
  end
end