adding functionality to list properties with values
This commit is contained in:
parent
cc2b183946
commit
04ad16a396
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -6,3 +6,5 @@ Gemfile*
|
|||
.rvmrc
|
||||
.bundle
|
||||
couchdb.std*
|
||||
*.*~
|
||||
|
||||
|
|
|
@ -23,6 +23,12 @@ module CouchRest
|
|||
self.class.properties
|
||||
end
|
||||
|
||||
def properties_with_values
|
||||
props = {}
|
||||
properties.each { |property| props[property.name] = read_attribute(property.name) }
|
||||
props
|
||||
end
|
||||
|
||||
def apply_all_property_defaults
|
||||
return if self.respond_to?(:new?) && (new? == false)
|
||||
# TODO: cache the default object
|
||||
|
@ -105,3 +111,4 @@ module CouchRest
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -36,6 +36,11 @@ describe "Model properties" do
|
|||
@card.properties.map{|p| p.name}.should include("first_name")
|
||||
end
|
||||
|
||||
it "should list object properties with values" do
|
||||
@card.properties_with_values.should be_an_instance_of(Hash)
|
||||
@card.properties_with_values["first_name"].should == "matt"
|
||||
end
|
||||
|
||||
it "should let you access a property value (getter)" do
|
||||
@card.first_name.should == "matt"
|
||||
end
|
||||
|
@ -838,3 +843,4 @@ describe "Property Class" do
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue