Class: SimpleParams::NestedClassList
- Inherits:
-
Object
- Object
- SimpleParams::NestedClassList
- Defined in:
- lib/simple_params/nested_class_list.rb
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #class_instances ⇒ Object
- #get_class_key(klass) ⇒ Object
-
#initialize(parent) ⇒ NestedClassList
constructor
A new instance of NestedClassList.
- #to_hash ⇒ Object
Constructor Details
#initialize(parent) ⇒ NestedClassList
Returns a new instance of NestedClassList.
5 6 7 |
# File 'lib/simple_params/nested_class_list.rb', line 5 def initialize(parent) @parent = parent end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
3 4 5 |
# File 'lib/simple_params/nested_class_list.rb', line 3 def parent @parent end |
Instance Method Details
#class_instances ⇒ Object
23 24 25 26 27 28 |
# File 'lib/simple_params/nested_class_list.rb', line 23 def class_instances nested_class_hash.each_pair.inject([]) do |array, (_key, value)| array << value array.flatten.compact end end |
#get_class_key(klass) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/simple_params/nested_class_list.rb', line 13 def get_class_key(klass) nested_class_hash.each do |key, value| if value.is_a?(Array) return key if value.include?(klass) else return key if value == klass end end end |
#to_hash ⇒ Object
9 10 11 |
# File 'lib/simple_params/nested_class_list.rb', line 9 def to_hash nested_class_hash end |