added documentation
This commit is contained in:
parent
402ef4e491
commit
5287f5e5ac
|
@ -8,7 +8,11 @@ class Polecat
|
||||||
:value => nil
|
:value => nil
|
||||||
}
|
}
|
||||||
|
|
||||||
def self.included klass
|
# include the document
|
||||||
|
#
|
||||||
|
# This includes the document into the target class.
|
||||||
|
# @private
|
||||||
|
def self.included klass #:nodoc:
|
||||||
klass.extend(DocumentResource)
|
klass.extend(DocumentResource)
|
||||||
klass.instance_variable_set :@attributes, {}
|
klass.instance_variable_set :@attributes, {}
|
||||||
end
|
end
|
||||||
|
@ -17,14 +21,14 @@ class Polecat
|
||||||
#
|
#
|
||||||
# It is possible to create a new document with a hash, which has all values
|
# It is possible to create a new document with a hash, which has all values
|
||||||
# of the fields.
|
# of the fields.
|
||||||
# Example:
|
# @example initializing a document
|
||||||
# class Foo
|
# class Foo
|
||||||
# include Polecat::Document
|
# include Polecat::Document
|
||||||
#
|
#
|
||||||
# field :id
|
# field :id
|
||||||
# field :description
|
# field :description
|
||||||
# end
|
# end
|
||||||
# f = Foo.new :id => 1, :description => 'foo'
|
# f = Foo.new :id => 1, :description => 'foo'
|
||||||
def initialize fields = {}
|
def initialize fields = {}
|
||||||
fields.each do |key, value|
|
fields.each do |key, value|
|
||||||
attribute_set key, value
|
attribute_set key, value
|
||||||
|
|
Loading…
Reference in New Issue