Class: Autumn::OptionsProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/autumn/speciator.rb

Overview

:nodoc:

Constant Summary collapse

MERGED_METHODS =
[ :[], :each, :each_key, :each_pair, :each_value, :eql?,
:fetch, :has_key?, :include?, :key?, :member?, :has_value?, :value?,
:hash, :index, :inspect, :invert, :keys, :length, :size, :merge, :reject,
:select, :sort, :to_a, :to_hash, :to_s, :values, :values_at ]

Instance Method Summary collapse

Constructor Details

#initialize(*hashes) ⇒ OptionsProxy

Returns a new instance of OptionsProxy.

Raises:

  • (ArgumentError)


142
143
144
145
146
# File 'lib/autumn/speciator.rb', line 142

def initialize(*hashes)
  raise ArgumentError unless hashes.all? { |hsh| hsh.kind_of? Hash }
  @hashes = hashes
  @hashes << Hash.new # the runtime settings, which take precedence over all
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



148
149
150
151
152
153
154
# File 'lib/autumn/speciator.rb', line 148

def method_missing(meth, *args, &block)
  if MERGED_METHODS.include? meth then
    merged.send meth, *args, &block
  else
    @hashes.last.send meth, *args, &block
  end
end