Module: PoolParty::MethodMissingSugar

Included in:
Base, PluginModel::PluginModel, Pool::Pool
Defined in:
lib/poolparty/modules/method_missing_sugar.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



4
5
6
7
8
9
10
# File 'lib/poolparty/modules/method_missing_sugar.rb', line 4

def method_missing(m, *args, &block)
  if block_given?
    (args[0].class == self.class) ? args[0].instance_eval(&block) : super
  else
    get_from_options(m, *args)
  end
end

Instance Method Details

#get_from_options(m, *args) ⇒ Object



12
13
14
# File 'lib/poolparty/modules/method_missing_sugar.rb', line 12

def get_from_options(m, *args)
  args.empty? ? options[m] : options[m] = (args.is_a?(Array) && args.size > 1) ? args : args[0]
end