Module: Ascribe::Attributes::ClassMethods

Defined in:
lib/ascribe/attributes.rb

Instance Method Summary collapse

Instance Method Details

#attribute(*args) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/ascribe/attributes.rb', line 26

def attribute(*args)
  Ascribe::Attribute.new(*args).tap do |attribute|
    attributes[attribute.name.to_s] = attribute
    create_attribute_in_descendants(*args)
    create_validations_for(attribute)
  end
end

#attributesObject



22
23
24
# File 'lib/ascribe/attributes.rb', line 22

def attributes
  @attributes ||= {}
end

#inherited(base) ⇒ Object



17
18
19
20
# File 'lib/ascribe/attributes.rb', line 17

def inherited(base)
  base.instance_variable_set(:@attributes, attributes.dup)
  super
end