No commit activity in last 3 years
No release in over 3 years
Acts as a Parameter Object cf. Refactoring: Ruby Edition
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
~> 2.11

Runtime

 Project Readme

acts_as_parameter_object

testing ruby: 1.9.3, 2.0.0

About acts_as_parameter_object

ActsAsParameterObject creates a model which acts as a Parameter Object. cf. Refactoring: Ruby Edition.

Example

class ParameterObjectExample
  include ActsAsParameterObject

  attr_accessor :title
  validates_presence_of :title

  def initialize(params = {})
    @title = params[:title]
  end
end

ParameterObjectExample.new(:foo => 'bar').valid? #=> false

You can use all of ActiveModel::Validations methods.

I use a parameter object as a validator model for params coming from rails controller. In contrast to ActiveRecord, this model does not access to the database.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Copyright

Copyright (c) 2013 Naotoshi SEO. See LICENSE for details.