lib/ig_markets/model.rb
# Defines setter and getter instance methods and a sanitizer class method for a new attribute on this class.
#
# @param [Symbol] name The name of the new attribute.
# @param [Boolean, String, Date, Time, Integer, Float, Symbol, Model] type The attribute's type.
# @param [Hash] options The configuration options for the new attribute.
# @option options [Array] :allowed_values The set of values that this attribute is allowed to be set to. An
#                 attempt to set this attribute to a value not in this list will raise `ArgumentError`. Optional.
# @option options [Array] :nil_if Values that, when set on the attribute, should be converted to `nil`.
# @option options [Regexp] :regex When `type` is `String` only values matching this regex will be allowed.
#                 Optional.
# @option options [String] :format When `type` is `Date` or `Time` this specifies the format or formats for
#                 parsing String and `Integer` instances assigned to this attribute.
#
# @macro [attach] attribute
#   The $1 attribute.
#   @return [$2]
Defines setter and getter instance methods and a sanitizer class method for a new attribute on this class.
Defines setter and getter instance methods and a sanitizer class method for a new attribute on this class .
def attribute(name, type = String, options = {})
        define_attribute_reader name
        define_attribute_writer name
        define_attribute_sanitizer name, type, options
        @defined_attributes ||= {}
        @defined_attributes[name] = options.merge type: type
      end
def attribute ( name , type = String , options = { } ) define_attribute_reader name define_attribute_writer name define_attribute_sanitizer name , type , options @defined_attributes ||= { } @defined_attributes [ name ] = options . merge type : type end
Defines setter and getter instance methods and a sanitizer class method for a new attribute on this class.
Defines setter and getter instance methods and a sanitizer class method for a new attribute on this class .
name
type
options
:format When `type` is `Date` or `Time` this specifies the format or formats for parsing String and `Integer` instances assigned to this attribute.
: format When ` type ` is ` Date ` or ` Time ` this specifies the format or formats for parsing String and ` Integer ` instances assigned to this attribute .
options The configuration options for the new attribute.
options The configuration options for the new attribute .
macro
[attach] attribute The $1 attribute.
[ attach ] attribute The $1 attribute .