Class: CouchRest::Model::Proxyable::ModelProxy
- Inherits:
-
Object
- Object
- CouchRest::Model::Proxyable::ModelProxy
- Defined in:
- lib/couchrest/model/proxyable.rb
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#owner_name ⇒ Object
readonly
Returns the value of attribute owner_name.
Instance Method Summary collapse
- #build_from_database(attrs = {}, options = {}, &block) ⇒ Object
-
#count(opts = {}) ⇒ Object
From DocumentQueries (The old fashioned way).
- #first(opts = {}) ⇒ Object
- #get(id) ⇒ Object (also: #find)
-
#initialize(model, owner, owner_name, database) ⇒ ModelProxy
constructor
A new instance of ModelProxy.
- #last(opts = {}) ⇒ Object
-
#new(attrs = {}, options = {}, &block) ⇒ Object
Base.
Constructor Details
#initialize(model, owner, owner_name, database) ⇒ ModelProxy
Returns a new instance of ModelProxy.
73 74 75 76 77 78 79 80 |
# File 'lib/couchrest/model/proxyable.rb', line 73 def initialize(model, owner, owner_name, database) @model = model @owner = owner @owner_name = owner_name @database = database create_view_methods end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
71 72 73 |
# File 'lib/couchrest/model/proxyable.rb', line 71 def database @database end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
71 72 73 |
# File 'lib/couchrest/model/proxyable.rb', line 71 def model @model end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
71 72 73 |
# File 'lib/couchrest/model/proxyable.rb', line 71 def owner @owner end |
#owner_name ⇒ Object (readonly)
Returns the value of attribute owner_name.
71 72 73 |
# File 'lib/couchrest/model/proxyable.rb', line 71 def owner_name @owner_name end |
Instance Method Details
#build_from_database(attrs = {}, options = {}, &block) ⇒ Object
87 88 89 |
# File 'lib/couchrest/model/proxyable.rb', line 87 def build_from_database(attrs = {}, = {}, &block) proxy_block_update(:build_from_database, attrs, , &block) end |
#count(opts = {}) ⇒ Object
From DocumentQueries (The old fashioned way)
93 94 95 |
# File 'lib/couchrest/model/proxyable.rb', line 93 def count(opts = {}) all(opts).count end |
#first(opts = {}) ⇒ Object
97 98 99 |
# File 'lib/couchrest/model/proxyable.rb', line 97 def first(opts = {}) all(opts).first end |
#get(id) ⇒ Object Also known as: find
105 106 107 |
# File 'lib/couchrest/model/proxyable.rb', line 105 def get(id) proxy_update(@model.get(id, @database)) end |
#last(opts = {}) ⇒ Object
101 102 103 |
# File 'lib/couchrest/model/proxyable.rb', line 101 def last(opts = {}) all(opts).last end |
#new(attrs = {}, options = {}, &block) ⇒ Object
Base
83 84 85 |
# File 'lib/couchrest/model/proxyable.rb', line 83 def new(attrs = {}, = {}, &block) proxy_block_update(:new, attrs, , &block) end |