method

attribute

Importance_0
v7.0.0 - Show latest stable - 0 notes - Class: ClassMethods
attribute(name, cast_type = nil, default: NO_DEFAULT_PROVIDED, **options) public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activemodel/lib/active_model/attributes.rb, line 19
      def attribute(name, cast_type = nil, default: NO_DEFAULT_PROVIDED, **options)
        name = name.to_s

        cast_type = Type.lookup(cast_type, **options) if Symbol === cast_type
        cast_type ||= attribute_types[name]

        self.attribute_types = attribute_types.merge(name => cast_type)
        define_default_attribute(name, default, cast_type)
        define_attribute_method(name)
      end
Register or log in to add new notes.