Module: Micon::Helper

Defined in:
lib/micon/helper.rb

Overview

Generates helper methods for Micon, so you can use micon.config instead of micon

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/micon/helper.rb', line 6

def method_missing m, *args, &block
  super if args.size > 1 or block

  key = m.to_s.sub(/[?=]$/, '').to_sym
  self.class.class_eval do
    define_method key do
      self[key]
    end

    define_method "#{key}=" do |value|
      self[key] = value
    end

    define_method "#{key}?" do
      include? key
    end
  end

  send m, *args
end