Skip to content

Commit

Permalink
Merge pull request #150 from mckinnsb/master
Browse files Browse the repository at this point in the history
Implements to_sym for CouchRest::Model::Property
  • Loading branch information
samlown committed Sep 4, 2012
2 parents 9ea4a48 + 01c08f5 commit 11201fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/couchrest/model/property.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ def initialize(name, type = nil, options = {})
def to_s
name
end

def to_sym
@_sym_name ||= name.to_sym
end

# Cast the provided value using the properties details.
def cast(parent, value)
Expand Down
6 changes: 6 additions & 0 deletions spec/unit/property_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,12 @@
property.to_s.should eql('test')
end

it "should provide name as a symbol" do
property = CouchRest::Model::Property.new(:test, String)
property.name.to_sym.should eql(:test)
property.to_sym.should eql(:test)
end

it "should provide class from type" do
property = CouchRest::Model::Property.new(:test, String)
property.type_class.should eql(String)
Expand Down

0 comments on commit 11201fa

Please sign in to comment.