Class: Ducklink::Params
- Inherits:
-
Object
- Object
- Ducklink::Params
- Defined in:
- lib/ducklink.rb
Instance Attribute Summary collapse
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #group(&block) ⇒ Object
- #host(*domains, &block) ⇒ Object
-
#initialize(settings = {}) ⇒ Params
constructor
A new instance of Params.
- #set(key, value) ⇒ Object
- #template(template = nil) ⇒ Object
Constructor Details
#initialize(settings = {}) ⇒ Params
Returns a new instance of Params.
43 44 45 |
# File 'lib/ducklink.rb', line 43 def initialize(settings = {}) @settings = settings end |
Instance Attribute Details
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
41 42 43 |
# File 'lib/ducklink.rb', line 41 def settings @settings end |
Instance Method Details
#[](key) ⇒ Object
51 52 53 |
# File 'lib/ducklink.rb', line 51 def [](key) settings[key.to_s] end |
#group(&block) ⇒ Object
59 60 61 |
# File 'lib/ducklink.rb', line 59 def group(&block) Params.new(settings.clone).instance_exec &block end |
#host(*domains, &block) ⇒ Object
63 64 65 66 67 |
# File 'lib/ducklink.rb', line 63 def host(*domains, &block) domains.each do |domain| Ducklink::Decorator.host domain, Params.new(settings.clone), &block end end |
#set(key, value) ⇒ Object
47 48 49 |
# File 'lib/ducklink.rb', line 47 def set(key, value) settings[key.to_s] = value.to_s end |
#template(template = nil) ⇒ Object
55 56 57 |
# File 'lib/ducklink.rb', line 55 def template(template = nil) template ? set(:template, template) : self[:template] end |