Class: ActiveConfig::HashWithHooks

Inherits:
HashConfig show all
Defined in:
lib/active_config/suffixes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from HashConfig

#[], #[]=, _make_indifferent, _make_indifferent_and_freeze, #default, #delete, #dup, #fetch, #freeze!, #initialize, #key?, #merge, #method_missing, recursive_freeze, #regular_update, #to_hash, #update, #values_at

Methods inherited from Hash

#weave, #weave!

Constructor Details

This class inherits a constructor from ActiveConfig::HashConfig

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveConfig::HashConfig

Instance Attribute Details

#write_hooksObject

Returns the value of attribute write_hooks.



3
4
5
# File 'lib/active_config/suffixes.rb', line 3

def write_hooks
  @write_hooks
end

Instance Method Details

#add_write_hook(func = nil, &block) ⇒ Object



12
13
14
15
16
# File 'lib/active_config/suffixes.rb', line 12

def add_write_hook func=nil,&block
  self.write_hooks||=[]
  self.write_hooks << func if Proc===func
  self.write_hooks << block if Kernel.block_given?
end

#regular_writer(*args) ⇒ Object



8
9
10
11
# File 'lib/active_config/suffixes.rb', line 8

def regular_writer *args 
  write_hooks.each{|p|p.call}
  regular_writer_hwh(*args)
end

#regular_writer_hwhObject



4
# File 'lib/active_config/suffixes.rb', line 4

alias_method :regular_writer_hwh, :regular_writer