module Tutor::Attributes::ClassMethods

Public Instance Methods

attributes() click to toggle source
# File lib/tutor/attributes.rb, line 8
def attributes
  base_attributes = self.superclass.respond_to?(:attributes) ? self.superclass.attributes : []
  (__attributes + base_attributes).uniq(&:name)
end
has_attribute?(name) click to toggle source
# File lib/tutor/attributes.rb, line 13
def has_attribute?(name)
  attributes.any? { |attribute| attribute.name == name }
end

Protected Instance Methods

attribute(name, options = {}) click to toggle source
# File lib/tutor/attributes.rb, line 19
def attribute(name, options = {})
  attribute = Tutor::Attributes::Attribute.new(name, options)
  attribute.tap do |a|
    __attributes << a
    a.add_attribute_methods(self)
  end
end

Private Instance Methods

__attributes() click to toggle source
# File lib/tutor/attributes.rb, line 29
def __attributes
  @attributes ||= []
end