No commit activity in last 3 years
No release in over 3 years
Declares attribute for Active Model objects
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.15
~> 5.0
~> 12.0
~> 0.49

Runtime

 Project Readme

ActiveModel::Attribute Build Status

Declares attributes for Active Model objects.

Installation

Add this line to your application's Gemfile:

gem "active_model-attribute"

And then execute:

$ bundle

Or install it yourself as:

$ gem install active_model-attribute

Usage

class User
  include ActiveModel::Attribute

  attribute :name, :string
  attribute :position, :string
  attribute :age, :integer
  attribute :active, :boolean

  alias_attribute :full_name, :name
end

user = User.new(
  name: 'Bob',
  position: 'Developer',
  age: '42',
  active: false
)

user.age
# => 42

user.age.class
# => Integer

user.full_name
# => 'Bob'

user.active?
# => false

License

The gem is available as open source under the terms of the MIT License.