Class: YiffSpace::ConfigBuilder::SubconfigProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/yiffspace/config_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(owner, path) ⇒ SubconfigProxy

Returns a new instance of SubconfigProxy.



150
151
152
153
# File 'lib/yiffspace/config_builder.rb', line 150

def initialize(owner, path)
  @owner = owner
  @path  = path
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



155
156
157
158
159
160
161
162
163
164
165
# File 'lib/yiffspace/config_builder.rb', line 155

def method_missing(name, *, &)
  name      = name.to_sym
  full_path = @path + [name]

  flat = full_path.join("_").to_sym
  return @owner.public_send(flat, *, &) if @owner.respond_to?(flat)

  return SubconfigProxy.new(@owner, full_path) if subconfig_path?(full_path)

  super
end

Instance Method Details

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

Returns:

  • (Boolean)


167
168
169
170
171
172
173
174
# File 'lib/yiffspace/config_builder.rb', line 167

def respond_to_missing?(name, include_private = false)
  name = name.to_sym
  flat = (@path + [name]).join("_").to_sym

  @owner.respond_to?(flat, include_private) ||
    subconfig_path?(@path + [name]) ||
    super
end