Class: ActionHooks::Configuration
- Inherits:
-
Object
- Object
- ActionHooks::Configuration
- Defined in:
- lib/action_hooks/configuration.rb
Instance Method Summary collapse
- #add_source(name) {|source| ... } ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #source(name) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
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
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 |