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.



53
54
55
56
57
# File 'lib/js_routes.rb', line 53

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

Instance Method Details

#[](attribute) ⇒ Object



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

def [](attribute)
  send(attribute)
end

#assign(attributes) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/js_routes.rb', line 59

def assign(attributes)
  attributes.each do |attribute, value|
    value = value.call if value.is_a?(Proc)
    send(:"#{attribute}=", value)
  end
  self
end

#esm?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/js_routes.rb', line 79

def esm?
  self.module_type === 'ESM'
end

#merge(attributes) ⇒ Object



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

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

#to_hashObject



75
76
77
# File 'lib/js_routes.rb', line 75

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