0.05
No commit activity in last 3 years
No release in over 3 years
Like `ActiveModel::Attributes` but less fluffy and more attribute-y.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.15
~> 0.11.3
~> 10.0
~> 3.0
 Project Readme

Attributary

Like ActiveModel::Attributes or Virtus but not. No dependencies.

Installation

Add this line to your application's Gemfile:

gem 'attributary'

And then execute:

$ bundle

Or install it yourself as:

$ gem install attributary

Usage

class Character
  include Attributary::DSL
  include Attributary::Initializer
  
  attribute :age, :integer
  attribute :description, :string, :validate => :check_description
  attribute :gender, :string, :collection => ['male', 'female', 'other']
  
  # if you don't need to initialize anything yourself, you can omit this
  def initialize(name, options = {})
    @name = name 
    attributary_attributes(options)
  end
  
  private
  
  def check_description
    description.length <= 1024
  end
end

character = Character.new("Tommy", :age => 16, :description => "Hi I am Tommy", :gender => 'male')
character.age # 16
character.description # Hi I am Tommy
character.gender # male 

character.age = 18
character.age # 18

Lots more info on the Wiki

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/joshmn/attributary