Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

active_model_coercions

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

active_model_coercions

bundlerRubygems
Version
0.1.0
Version published
Maintainers
1
Created
Source

ActiveModelCoercions

Currently, it's just an experimental coercion proof of concept for ActiveModel objects. However if you see some areas of improvement or want to discuss some stuff - feel free to open an issue/pull request.

Installation

Add this line to your application's Gemfile:

gem 'active_model_coercions'

And then execute:

$ bundle

Or install it yourself as:

$ gem install active_model_coercions

Usage

class TestModel
  include ActiveModel::Model
  include ActiveModel::Coercions


  attr_accessor :number, :date, :state

  attribute :number, :integer
  attribute :state, :symbol

end
params = {number: '1', state: 'active'}
model = TestModel.new(params)

model.number # => 1
model.state # => :active
model.attributes # => {number: 1, state: :active}

Contributing

  • Fork it
  • Create your feature branch (git checkout -b feature-branch)
  • Commit your changed (git commit -a -m 'Add some changes')
  • Push feature branch to github (git push origin feature-branch)
  • Create pull request

License

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

FAQs

Package last updated on 22 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts