Class: CouchRest::Model::Proxyable::ModelProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/couchrest/model/proxyable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#databaseObject (readonly)

Returns the value of attribute database.



71
72
73
# File 'lib/couchrest/model/proxyable.rb', line 71

def database
  @database
end

#modelObject (readonly)

Returns the value of attribute model.



71
72
73
# File 'lib/couchrest/model/proxyable.rb', line 71

def model
  @model
end

#ownerObject (readonly)

Returns the value of attribute owner.



71
72
73
# File 'lib/couchrest/model/proxyable.rb', line 71

def owner
  @owner
end

#owner_nameObject (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 = {}, options = {}, &block)
  proxy_block_update(:build_from_database, attrs, options, &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 = {}, options = {}, &block)
  proxy_block_update(:new, attrs, options, &block)
end