lib/lean-attributes/attributes/class_methods.rb
def attribute(name, type, options = {})
        attribute = Attribute.new(
          default:  options[:default],
          name:     name,
          type:     type
        )

        defined_attributes << attribute.name
        attribute_defaults[name] = attribute.default

        add_attribute_methods(attribute)
        add_type_coercion_method(attribute.type)

        attribute
      end
# Defines a new attribute. Adds getter and setter methods to the class.
#
# @param [Symbol] name attribute name that will be used as an attribute
#                      reader and writer
# @param [Class,String,Symbol] type class or class name of the attribute
# @param [Hash] options
# @option options [Object] :default default value or Proc to call
# @return [Attribute] configured Attribute
#
# @see #add_attribute_methods
# @see #add_type_coercion_method
# @see #attribute_defaults
# @see #defined_attributes
Defines a new attribute. Adds getter and setter methods to the class.
Defines a new attribute . Adds getter and setter methods to the class .
def attribute(name, type, options = {})
        attribute = Attribute.new(
          default:  options[:default],
          name:     name,
          type:     type
        )
        defined_attributes << attribute.name
        attribute_defaults[name] = attribute.default
        add_attribute_methods(attribute)
        add_type_coercion_method(attribute.type)
        attribute
      end
def attribute ( name , type , options = { } ) attribute = Attribute . new ( default : options [ :default ] , name : name , type : type ) defined_attributes << attribute . name attribute_defaults [ name ] = attribute . default add_attribute_methods ( attribute ) add_type_coercion_method ( attribute . type ) attribute end
Defines a new attribute.
Defines a new attribute .
None
Attribute
name
type
options
:default default value or Proc to call
: default default value or Proc to call
None
see
None
see
None
see
None
see
None