Browse files

Merge pull request #150 from mckinnsb/master

Implements to_sym for CouchRest::Model::Property
  • Loading branch information...
2 parents 9ea4a48 + 01c08f5 commit 11201fa4e6925ba7af20f4b0d750239c97d8d626 @samlown samlown committed Sep 4, 2012
Showing with 10 additions and 0 deletions.
  1. +4 −0 lib/couchrest/model/property.rb
  2. +6 −0 spec/unit/property_spec.rb
View
4 lib/couchrest/model/property.rb
@@ -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)
View
6 spec/unit/property_spec.rb
@@ -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)

0 comments on commit 11201fa

Please sign in to comment.