Module: Cupcakinator

Defined in:
lib/cupcakinator.rb,
lib/cupcakinator/base.rb,
lib/cupcakinator/config.rb,
lib/cupcakinator/errors.rb,
lib/cupcakinator/options.rb,
lib/cupcakinator/version.rb

Overview

the purpose of cupcakinator is to provide an simple, flexible dynamic method to retrrieve configuration data for a class it provides this dynamic method as ‘config’ by default for both the class and any instances

Examples:

class Foo uses cupcakinator, see Cupcakinator::Base::cupcakinate

given config.yml:
bacon:
  flavor: pork
meatball:
  flavor:
    - pork
    - chicken
>> Foo.config
{"meatball"=>{"flavor"=>["chicken", "pork"]}}
>> Foo.config.meatball
{"flavor"=>["chicken", "pork"]}

Defined Under Namespace

Modules: Base Classes: Config, ConfigFileInvalidError, ConfigFileNotFoundError, Options

Constant Summary collapse

VERSION =
'2.0.0'

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(original_method, *args) ⇒ Object



136
137
138
139
140
141
142
# File 'lib/cupcakinator/base.rb', line 136

def method_missing(original_method, *args)
  if original_method.to_s == self.class._cupcakinator_options[:method].to_s
     self.class._cupcakinator_config(*args)
  else
    super
  end
end

Class Method Details

.included(other) ⇒ Object



33
34
35
# File 'lib/cupcakinator.rb', line 33

def self.included(other)
  other.extend Cupcakinator::Base
end