Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements to_sym for CouchRest::Model::Property #150

Merged
merged 1 commit into from
Sep 4, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -393,6 +393,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