module Ceres::AttributeModule::Singleton

Public Instance Methods

attribute(name, &block) click to toggle source
# 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) click to toggle source
# 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