Module: Observed::Configurable::ModuleMethods
- Defined in:
- lib/observed/configurable.rb
Instance Method Summary collapse
- #attribute(name, options = {}) ⇒ Object
- #attributes ⇒ Object
- #ensure_configurable(klass) ⇒ Object
- #included(klass) ⇒ Object
Instance Method Details
#attribute(name, options = {}) ⇒ Object
66 67 68 69 |
# File 'lib/observed/configurable.rb', line 66 def attribute(name, ={}) @attributes ||= {} @attributes = @attributes.merge(name => ) end |
#attributes ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/observed/configurable.rb', line 71 def attributes @attributes || fail(<<EOS #{self} includes Observed::Configurable. Though, no attributes are configured for #{self}. We don't need to include Observed::Configurable, or it might be a bug? EOS ) end |
#ensure_configurable(klass) ⇒ Object
88 89 90 91 92 |
# File 'lib/observed/configurable.rb', line 88 def ensure_configurable(klass) unless klass.include? Configurable fail "The class #{klass} must include Observed::Configurable to include #{self}" end end |
#included(klass) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/observed/configurable.rb', line 80 def included(klass) ensure_configurable klass attributes.each do |name, | klass.attribute name, end end |