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

- (ModelProxy) initialize(model, owner, owner_name, database)



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

- (Object) database (readonly)

Returns the value of attribute database



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

def database
  @database
end

- (Object) model (readonly)

Returns the value of attribute model



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

def model
  @model
end

- (Object) owner (readonly)

Returns the value of attribute owner



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

def owner
  @owner
end

- (Object) owner_name (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

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



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

- (Object) count(opts = {})

From DocumentQueries (The old fashioned way)



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

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

- (Object) first(opts = {})



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

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

- (Object) get(id) 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

- (Object) last(opts = {})



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

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

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

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