Module: TarvitHelpers::HashPresenter

Defined in:
lib/tarvit-helpers/modules/hash_presenter.rb,
lib/tarvit-helpers/modules/hash_presenter/cached.rb,
lib/tarvit-helpers/modules/hash_presenter/custom.rb,
lib/tarvit-helpers/modules/hash_presenter/simple.rb,
lib/tarvit-helpers/modules/hash_presenter/observable.rb,
lib/tarvit-helpers/modules/hash_presenter/with_rules.rb

Defined Under Namespace

Classes: Cached, Custom, Observable, Simple, WithRules

Class Method Summary collapse

Class Method Details

.factoryObject



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

def self.factory
  { cached: Cached, observable: Observable }
end

.present(hash, option = :cached) ⇒ Object

Raises:

  • (ArgumentError)


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

def self.present(hash, option = :cached )
  raise ArgumentError.new("#{ hash.class } is not a Hash") unless hash.is_a?(Hash)
  factory[option].new(hash)
end