Class: Maglev::Site::StyleValue::Store

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
app/models/maglev/site/style_value.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(array) ⇒ Store

Returns a new instance of Store.



20
21
22
# File 'app/models/maglev/site/style_value.rb', line 20

def initialize(array)
  @array = array
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *_args) ⇒ Object



24
25
26
27
28
29
30
31
# File 'app/models/maglev/site/style_value.rb', line 24

def method_missing(method_name, *_args)
  setting = array.find { |local_setting| local_setting.id == method_name.to_s }
  if setting
    setting.value
  else
    super
  end
end

Instance Attribute Details

#arrayObject (readonly)

Returns the value of attribute array.



18
19
20
# File 'app/models/maglev/site/style_value.rb', line 18

def array
  @array
end

Instance Method Details

#as_json(**_options) ⇒ Object



38
39
40
# File 'app/models/maglev/site/style_value.rb', line 38

def as_json(**_options)
  @array.as_json
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
# File 'app/models/maglev/site/style_value.rb', line 33

def respond_to_missing?(method_name, include_private = false)
  Rails.logger.debug 'yeasss!!!'
  array.map(&:id).include?(method_name.to_s) || super
end