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.



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

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

Instance Method Details

#[](attribute) ⇒ Object



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

def [](attribute)
  send(attribute)
end

#assign(attributes) ⇒ Object



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

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



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

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

#to_hashObject



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

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