Class: ActionHooks::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/action_hooks/configuration.rb

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



19
20
21
# File 'lib/action_hooks/configuration.rb', line 19

def initialize
  @sources = {}
end

Instance Method Details

#add_source(name) {|source| ... } ⇒ Object

Yields:



23
24
25
26
27
# File 'lib/action_hooks/configuration.rb', line 23

def add_source(name)
  source = Source.new(name)
  yield(source) if block_given?
  @sources[name.to_sym] = source
end

#source(name) ⇒ Object



29
30
31
32
33
# File 'lib/action_hooks/configuration.rb', line 29

def source(name)
  @sources.fetch(name.to_sym)
rescue KeyError
  raise SourceNotDefinedError, "Source :#{name} is not defined in ActionHooks configuration"
end