module ActiveAny::Attribute::ClassMethods

Public Instance Methods

attribute(name) click to toggle source
# File lib/active_any/attribute.rb, line 48
def attribute(name)
  attribute_names << name.to_sym
  define_writer_method name
  define_reader_method name
end
attribute_names() click to toggle source
# File lib/active_any/attribute.rb, line 54
def attribute_names
  @attribute_names ||= []
end
attributes(*names) click to toggle source
# File lib/active_any/attribute.rb, line 44
def attributes(*names)
  names.each { |name| attribute name }
end
define_reader_method(name) click to toggle source
# File lib/active_any/attribute.rb, line 64
def define_reader_method(name)
  define_method name do
    attributes.fetch(name, nil)
  end
end
define_writer_method(name) click to toggle source
# File lib/active_any/attribute.rb, line 58
def define_writer_method(name)
  define_method "#{name}=" do |value|
    attributes[name] = value
  end
end
has_attribute?(attribute) click to toggle source
# File lib/active_any/attribute.rb, line 70
def has_attribute?(attribute)
  attribute_names.include?(attribute)
end