Class: BehaviorAppender

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ BehaviorAppender

Returns a new instance of BehaviorAppender.



3
4
5
# File 'lib/behavior_appender.rb', line 3

def initialize(klass)
  self.klass = klass
end

Instance Attribute Details

#klassObject

Returns the value of attribute klass.



2
3
4
# File 'lib/behavior_appender.rb', line 2

def klass
  @klass
end

Instance Method Details

#column(name, type, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/behavior_appender.rb', line 7

def column(name, type, options={})
  klass.class_eval do
    attr_reader name.to_sym unless instance_methods.include?(name.to_s)
    attr_writer name.to_sym unless instance_methods.include?("#{name}=")
    if type.to_sym == :boolean
      define_method "#{name}?".to_sym do
        self.send name
      end
    end
  end
end