Class: BetterHelpers::HashHierarchyToClass

Inherits:
Object
  • Object
show all
Defined in:
lib/better_helpers/hash_hierarchy_to_class.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash, parent_class) ⇒ HashHierarchyToClass

Returns a new instance of HashHierarchyToClass.



4
5
6
7
# File 'lib/better_helpers/hash_hierarchy_to_class.rb', line 4

def initialize hash, parent_class
  @hash = hash
  @parent_class = parent_class
end

Instance Method Details

#applyObject



9
10
11
12
# File 'lib/better_helpers/hash_hierarchy_to_class.rb', line 9

def apply
  value = apply_to_class @hash, @parent_class.new
  @hash.keys.first.nil? ? value : @parent_class.new
end