Module: Formotion::Formable::ClassMethods
- Defined in:
- lib/formotion/model/formable.rb
Constant Summary collapse
- INHERITABLE_ATTRIBUTES =
[:form_properties, :form_title].each do |prop| attr_accessor prop end
Instance Method Summary collapse
- #form_properties ⇒ Object
-
#form_property(property, row_type, options = {}) ⇒ Object
Relates a property to a RowType.
-
#form_title(title = -1)) ⇒ Object
Sets the top bar title for this model EX form_title “Some Settings”.
-
#inherited(subclass) ⇒ Object
Does NOT get called when KVO occurs.
Instance Method Details
#form_properties ⇒ Object
21 22 23 24 |
# File 'lib/formotion/model/formable.rb', line 21 def form_properties @form_properties ||= self.superclass.form_properties if is_kvo_subclass? @form_properties ||= [] end |
#form_property(property, row_type, options = {}) ⇒ Object
Relates a property to a RowType. EX form_property :my_title => :string form_property :my_date => :date, :transform => lambda { |value| some_function(date) }
36 37 38 |
# File 'lib/formotion/model/formable.rb', line 36 def form_property(property, row_type, = {}) self.form_properties << { property: property, row_type: row_type}.merge() end |
#form_title(title = -1)) ⇒ Object
Sets the top bar title for this model EX form_title “Some Settings”
43 44 45 46 47 |
# File 'lib/formotion/model/formable.rb', line 43 def form_title(title = -1) @form_title ||= self.superclass.form_title if is_kvo_subclass? @form_title = title if title != -1 @form_title end |
#inherited(subclass) ⇒ Object
Does NOT get called when KVO occurs. (KVO uses isa swizzling and not proper subclassing)
14 15 16 17 18 19 |
# File 'lib/formotion/model/formable.rb', line 14 def inherited(subclass) INHERITABLE_ATTRIBUTES.each do |inheritable_attribute| instance_var = "@#{inheritable_attribute}" subclass.instance_variable_set(instance_var, instance_variable_get(instance_var)) end end |