Class: HasHelpers::RedisConfigurable::ConfigStruct

Inherits:
Object
  • Object
show all
Defined in:
app/utils/has_helpers/redis_configurable.rb

Instance Method Summary collapse

Constructor Details

#initialize(klass, defaults) ⇒ ConfigStruct

Returns a new instance of ConfigStruct.



24
25
26
27
# File 'app/utils/has_helpers/redis_configurable.rb', line 24

def initialize(klass, defaults)
  @klass = klass
  @defaults = defaults
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'app/utils/has_helpers/redis_configurable.rb', line 37

def method_missing(name, *args)
  key = name.to_s.sub(/=$/, "").to_sym

  if name.to_s.end_with?("=")
    store_value(key, args.first)
  else
    fetch_value(key)
  end
end

Instance Method Details

#[](key) ⇒ Object



29
30
31
# File 'app/utils/has_helpers/redis_configurable.rb', line 29

def [](key)
  fetch_value(key)
end

#[]=(key, value) ⇒ Object



33
34
35
# File 'app/utils/has_helpers/redis_configurable.rb', line 33

def []=(key, value)
  store_value(key, value)
end

#respond_to_missing?(_name, _include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'app/utils/has_helpers/redis_configurable.rb', line 47

def respond_to_missing?(_name, _include_private = false)
  true
end