Skip to content

Commit

Permalink
Add TypecastedAttributes to Model, closes #74
Browse files Browse the repository at this point in the history
  • Loading branch information
cgriego committed Feb 15, 2012
1 parent 3e874e8 commit 8e35b6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/active_attr/model.rb
Expand Up @@ -4,6 +4,7 @@
require "active_attr/logger"
require "active_attr/mass_assignment_security"
require "active_attr/query_attributes"
require "active_attr/typecasted_attributes"
require "active_model"
require "active_support/concern"

Expand All @@ -27,6 +28,7 @@ module Model
include MassAssignmentSecurity
include AttributeDefaults
include QueryAttributes
include TypecastedAttributes

if defined? ActiveModel::Serializable
include ActiveModel::Serializable::JSON
Expand Down
6 changes: 6 additions & 0 deletions spec/functional/active_attr/model_spec.rb
Expand Up @@ -11,6 +11,7 @@ module ActiveAttr

attribute :first_name
attribute :last_name
attribute :age, :type => Integer

attr_protected :last_name

Expand Down Expand Up @@ -84,6 +85,11 @@ def self.name
model_class.human_attribute_name(:first_name).should == "First name"
end

it "typecasts attributes" do
subject.age = "29"
subject.age.should eql 29
end

context "attribute defaults" do
let :model_class do
Class.new do
Expand Down

0 comments on commit 8e35b6f

Please sign in to comment.