Module: Loco::Observable::ClassMethods

Defined in:
lib/motion-loco/observable.rb

Instance Method Summary collapse

Instance Method Details

#get_class_bindingsArray

An array of the model’s bindings

Returns:

  • (Array)


154
155
156
# File 'lib/motion-loco/observable.rb', line 154

def get_class_bindings
  @class_bindings ||= []
end

#get_class_propertiesArray

An array of the model’s properties used for saving the record

Returns:

  • (Array)


161
162
163
# File 'lib/motion-loco/observable.rb', line 161

def get_class_properties
  @class_properties ||= []
end

#observer(name, proc) ⇒ Object



147
148
149
150
# File 'lib/motion-loco/observable.rb', line 147

def observer(name, proc)
  @class_bindings = get_class_bindings
  @class_bindings << { proc: proc }
end

#property(name, proc = nil) ⇒ Object



136
137
138
139
140
141
142
143
144
145
# File 'lib/motion-loco/observable.rb', line 136

def property(name, proc=nil)
  attr_accessor name
  if proc.nil?
    @class_properties = get_class_properties
    @class_properties << name
  else
    @class_bindings = get_class_bindings
    @class_bindings << { name: name, proc: proc }
  end
end