Module: Tramway::Forms::Properties::ClassMethods
- Defined in:
- lib/tramway/forms/properties.rb
Overview
A collection of methods that would be using in users forms
Instance Method Summary collapse
-
#__ancestor_properties(klass = superclass) ⇒ Object
:reek:ManualDispatch { enabled: false }.
-
#__initialize_properties(subclass) ⇒ Object
:reek:UtilityFunction { enabled: false }.
- #__properties ⇒ Object
- #__set_properties(attributes) ⇒ Object
- #properties(*attributes) ⇒ Object
- #property(attribute) ⇒ Object
Instance Method Details
#__ancestor_properties(klass = superclass) ⇒ Object
:reek:ManualDispatch { enabled: false }
30 31 32 33 34 35 36 |
# File 'lib/tramway/forms/properties.rb', line 30 def __ancestor_properties(klass = superclass) superklass = klass.superclass return [] unless superklass.respond_to?(:properties) klass.properties + __ancestor_properties(superklass) end |
#__initialize_properties(subclass) ⇒ Object
:reek:UtilityFunction { enabled: false }
39 40 41 |
# File 'lib/tramway/forms/properties.rb', line 39 def __initialize_properties(subclass) subclass.instance_variable_set(:@properties, []) end |
#__properties ⇒ Object
25 26 27 |
# File 'lib/tramway/forms/properties.rb', line 25 def __properties (__ancestor_properties + @properties).uniq end |
#__set_properties(attributes) ⇒ Object
19 20 21 22 23 |
# File 'lib/tramway/forms/properties.rb', line 19 def __set_properties(attributes) attributes.each do |attribute| property(attribute) end end |
#properties(*attributes) ⇒ Object
15 16 17 |
# File 'lib/tramway/forms/properties.rb', line 15 def properties(*attributes) attributes.any? ? __set_properties(attributes) : __properties end |
#property(attribute) ⇒ Object
9 10 11 12 13 |
# File 'lib/tramway/forms/properties.rb', line 9 def property(attribute) @properties << attribute delegate attribute, to: :object end |