Class: BehaviorAppender
- Inherits:
-
Object
- Object
- BehaviorAppender
- Defined in:
- lib/behavior_appender.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#klass ⇒ Object
Returns the value of attribute klass.
Instance Method Summary collapse
- #column(name, type, options = {}) ⇒ Object
-
#initialize(klass) ⇒ BehaviorAppender
constructor
A new instance of BehaviorAppender.
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
#klass ⇒ Object
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, ={}) 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 |