Class: TarvitHelpers::HashPresenter::Simple

Inherits:
Object
  • Object
show all
Defined in:
lib/tarvit-helpers/modules/hash_presenter/simple.rb

Direct Known Subclasses

Cached, Observable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash, levels = [], parent = nil) ⇒ Simple

Returns a new instance of Simple.



9
10
11
12
13
# File 'lib/tarvit-helpers/modules/hash_presenter/simple.rb', line 9

def initialize(hash, levels=[], parent=nil)
  @_hash = _modify_hash(_prepare_keys(hash))
  @_levels = levels
  @_parent = parent
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object



19
20
21
22
# File 'lib/tarvit-helpers/modules/hash_presenter/simple.rb', line 19

def method_missing(m, *args)
  return _value(m) if _accessor_method?(m)
  super
end

Instance Attribute Details

#_hashObject (readonly)

Returns the value of attribute _hash.



7
8
9
# File 'lib/tarvit-helpers/modules/hash_presenter/simple.rb', line 7

def _hash
  @_hash
end

#_levelsObject (readonly)

Returns the value of attribute _levels.



7
8
9
# File 'lib/tarvit-helpers/modules/hash_presenter/simple.rb', line 7

def _levels
  @_levels
end

#_parentObject (readonly)

Returns the value of attribute _parent.



7
8
9
# File 'lib/tarvit-helpers/modules/hash_presenter/simple.rb', line 7

def _parent
  @_parent
end

Instance Method Details

#_root?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/tarvit-helpers/modules/hash_presenter/simple.rb', line 15

def _root?
  _parent.nil?
end