Class: JsRoutes::Configuration

Inherits:
Struct
  • Object
show all
Defined in:
lib/js_routes.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes = nil) ⇒ Configuration

Returns a new instance of Configuration.



49
50
51
52
53
# File 'lib/js_routes.rb', line 49

def initialize(attributes = nil)
  assign(DEFAULTS)
  return unless attributes
  assign(attributes)
end

Instance Method Details

#[](attribute) ⇒ Object



63
64
65
# File 'lib/js_routes.rb', line 63

def [](attribute)
  send(attribute)
end

#assign(attributes) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/js_routes.rb', line 55

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



67
68
69
# File 'lib/js_routes.rb', line 67

def merge(attributes)
  clone.assign(attributes)
end

#to_hashObject



71
72
73
# File 'lib/js_routes.rb', line 71

def to_hash
  Hash[*members.zip(values).flatten(1)].symbolize_keys
end