Module: Statistrano::Config::Configurable
- Included in:
- Deployment::Strategy::Base
- Defined in:
- lib/statistrano/config/configurable.rb
Class Method Summary collapse
-
.extended(extending_obj) ⇒ Object
add a config method to objects that extend Configurable.
Instance Method Summary collapse
- #configuration ⇒ Object
-
#inherited(subclass) ⇒ Object
make sure that classes that inherit from classes that have been configured also inherit the configuration of the parent class.
- #option(key, value = nil, proc = nil) ⇒ Object
- #options(*args) ⇒ Object
- #task(name, method, description) ⇒ Object
Class Method Details
.extended(extending_obj) ⇒ Object
add a config method to objects that extend Configurable
31 32 33 34 35 36 37 38 |
# File 'lib/statistrano/config/configurable.rb', line 31 def self.extended extending_obj extending_obj.send :define_method, :config, -> { @_config ||= Config.new( self.class.configuration., self.class.configuration.tasks ) } end |
Instance Method Details
#configuration ⇒ Object
5 6 7 |
# File 'lib/statistrano/config/configurable.rb', line 5 def configuration @_configuration ||= Config.new() end |
#inherited(subclass) ⇒ Object
make sure that classes that inherit from classes that have been configured also inherit the configuration of the parent class
44 45 46 47 48 49 |
# File 'lib/statistrano/config/configurable.rb', line 44 def inherited subclass subclass.superclass.class_eval do subclass.configuration..merge! subclass.superclass.configuration. subclass.configuration.tasks.merge! subclass.superclass.configuration.tasks end end |
#option(key, value = nil, proc = nil) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/statistrano/config/configurable.rb', line 9 def option key, value=nil, proc=nil if proc configuration.[key] = { call: proc } else configuration.[key] = value end end |
#options(*args) ⇒ Object
17 18 19 |
# File 'lib/statistrano/config/configurable.rb', line 17 def *args args.each { |a| option(a) } end |
#task(name, method, description) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/statistrano/config/configurable.rb', line 21 def task name, method, description configuration.tasks[name] = { method: method, desc: description } end |