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.



78
79
80
81
82
83
84
85
# File 'lib/couchrest/model/proxyable.rb', line 78

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.



76
77
78
# File 'lib/couchrest/model/proxyable.rb', line 76

def database
  @database
end

#modelObject (readonly)

Returns the value of attribute model.



76
77
78
# File 'lib/couchrest/model/proxyable.rb', line 76

def model
  @model
end

#ownerObject (readonly)

Returns the value of attribute owner.



76
77
78
# File 'lib/couchrest/model/proxyable.rb', line 76

def owner
  @owner
end

#owner_nameObject (readonly)

Returns the value of attribute owner_name.



76
77
78
# File 'lib/couchrest/model/proxyable.rb', line 76

def owner_name
  @owner_name
end

Instance Method Details

#build_from_database(attrs = {}, options = {}, &block) ⇒ Object



92
93
94
# File 'lib/couchrest/model/proxyable.rb', line 92

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)



98
99
100
# File 'lib/couchrest/model/proxyable.rb', line 98

def count(opts = {})
  all(opts).count
end

#first(opts = {}) ⇒ Object



102
103
104
# File 'lib/couchrest/model/proxyable.rb', line 102

def first(opts = {})
  all(opts).first
end

#get(id) ⇒ Object Also known as: find



110
111
112
# File 'lib/couchrest/model/proxyable.rb', line 110

def get(id)
  proxy_update(@model.get(id, @database))
end

#last(opts = {}) ⇒ Object



106
107
108
# File 'lib/couchrest/model/proxyable.rb', line 106

def last(opts = {})
  all(opts).last
end

#new(attrs = {}, options = {}, &block) ⇒ Object

Base



88
89
90
# File 'lib/couchrest/model/proxyable.rb', line 88

def new(attrs = {}, options = {}, &block)
  proxy_block_update(:new, attrs, options, &block)
end