Skip to content

Commit

Permalink
Add InstanceMethods#to_hash
Browse files Browse the repository at this point in the history
  • Loading branch information
solnic committed Jul 30, 2011
1 parent ab57077 commit f375f2b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/virtus/instance_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ def attributes=(attributes)
end
end

# @see Virtus::InstanceMethods#attributes
#
# @api public
def to_hash
attributes
end

private

# Returns a value of the attribute with the given name
Expand Down
7 changes: 7 additions & 0 deletions spec/unit/virtus/instance_methods/attributes_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'spec_helper'

# TODO: split this into separate files - solnic
describe Virtus do
let(:model) do
Class.new do
Expand All @@ -25,6 +26,12 @@
end
end

describe '#to_hash' do
it 'returns attributes' do
object.to_hash.should == object.attributes
end
end

describe "#attributes=" do
before do
object.attributes = attributes
Expand Down

0 comments on commit f375f2b

Please sign in to comment.