Class: Dmm::Base
- Inherits:
-
Object
- Object
- Dmm::Base
- Defined in:
- lib/dmm/base.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ Base
constructor
Initializes a new object.
Constructor Details
#initialize(attrs = {}) ⇒ Base
Initializes a new object
21 22 23 |
# File 'lib/dmm/base.rb', line 21 def initialize(attrs={}) @attrs = attrs end |
Class Method Details
.attr_reader(*attrs) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/dmm/base.rb', line 3 def self.attr_reader(*attrs) mod = Module.new do attrs.each do |attribute| define_method attribute do @attrs[attribute.to_sym] end define_method "#{attribute}?" do !!@attribute[attribute.to_sym] end end end const_set(:Attributes, mod) include mod end |