Class: JsRoutes::Configuration
- Inherits:
-
Struct
- Object
- Struct
- JsRoutes::Configuration
- Defined in:
- lib/js_routes.rb
Instance Method Summary collapse
- #[](attribute) ⇒ Object
- #assign(attributes) ⇒ Object
-
#initialize(attributes = nil) ⇒ Configuration
constructor
A new instance of Configuration.
- #merge(attributes) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(attributes = nil) ⇒ Configuration
Returns a new instance of Configuration.
44 45 46 47 48 |
# File 'lib/js_routes.rb', line 44 def initialize(attributes = nil) assign(DEFAULTS) return unless attributes assign(attributes) end |
Instance Method Details
#[](attribute) ⇒ Object
58 59 60 |
# File 'lib/js_routes.rb', line 58 def [](attribute) send(attribute) end |
#assign(attributes) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/js_routes.rb', line 50 def assign(attributes) attributes.each do |attribute, value| value = value.call if value.is_a?(Proc) send(:"#{attribute}=", value) end self end |
#merge(attributes) ⇒ Object
62 63 64 |
# File 'lib/js_routes.rb', line 62 def merge(attributes) clone.assign(attributes) end |
#to_hash ⇒ Object
66 67 68 |
# File 'lib/js_routes.rb', line 66 def to_hash Hash[*members.zip(values).flatten(1)].symbolize_keys end |