Module: Startback::Context::HFactory

Included in:
Startback::Context
Defined in:
lib/startback/context/h_factory.rb

Instance Method Summary collapse

Instance Method Details

#h(hash) ⇒ Object



10
11
12
# File 'lib/startback/context/h_factory.rb', line 10

def h(hash)
  h_factor!(self.new, hash)
end

#h_dump(&dumper) ⇒ Object



58
59
60
# File 'lib/startback/context/h_factory.rb', line 58

def h_dump(&dumper)
  h_dumpers << dumper
end

#h_dump!(context, hash = {}) ⇒ Object



39
40
41
42
43
44
# File 'lib/startback/context/h_factory.rb', line 39

def h_dump!(context, hash = {})
  h_dumpers.each do |d|
    context.instance_exec(hash, &d)
  end
  hash
end

#h_dumpersObject



50
51
52
# File 'lib/startback/context/h_factory.rb', line 50

def h_dumpers
  @h_dumpers ||= []
end

#h_dumpers=(dumpers) ⇒ Object



54
55
56
# File 'lib/startback/context/h_factory.rb', line 54

def h_dumpers=(dumpers)
  @h_dumpers = dumpers
end

#h_dumpers?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/startback/context/h_factory.rb', line 46

def h_dumpers?
  !!@h_dumpers && @h_dumpers.any?
end

#h_factor!(context, hash) ⇒ Object



14
15
16
17
18
19
# File 'lib/startback/context/h_factory.rb', line 14

def h_factor!(context, hash)
  h_factories.each do |f|
    f.call(context, hash)
  end
  context
end

#h_factoriesObject



29
30
31
# File 'lib/startback/context/h_factory.rb', line 29

def h_factories
  @h_factories ||= []
end

#h_factories=(factories) ⇒ Object



25
26
27
# File 'lib/startback/context/h_factory.rb', line 25

def h_factories=(factories)
  @h_factories = factories
end

#h_factories?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/startback/context/h_factory.rb', line 21

def h_factories?
  !!@h_factories && @h_factories.any?
end

#h_factory(&factory) ⇒ Object



33
34
35
# File 'lib/startback/context/h_factory.rb', line 33

def h_factory(&factory)
  h_factories << factory
end

#inherited(subclass) ⇒ Object



5
6
7
8
# File 'lib/startback/context/h_factory.rb', line 5

def inherited(subclass)
  subclass.h_factories = h_factories.dup if h_factories?
  subclass.h_dumpers = h_dumpers.dup if h_dumpers?
end