Module: Ceres::AttributeModule::Singleton
- Defined in:
- lib/ceres/attribute.rb
Instance Method Summary collapse
Instance Method Details
#attribute(name, &block) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/ceres/attribute.rb', line 12 def attribute(name, &block) attribute = Ceres::Attribute.new(name, &block) attribute.apply(self) @attributes ||= [] @attributes << attribute end |
#attributes(all: true) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ceres/attribute.rb', line 20 def attributes(all: true) if all self.ancestors.flat_map do |ancestor| if ancestor.respond_to?(:attributes) ancestor.attributes(all: false) else [] end end elsif defined?(@attributes) @attributes else [] end end |