Module: Og::EntityMixin::ClassMethods
- Defined in:
- lib/og/entity.rb
Instance Method Summary collapse
- #const_missing(sym) ⇒ Object
- #count(options = {}) ⇒ Object
- #create(*args) {|obj| ... } ⇒ Object
- #delete(obj_or_pk) ⇒ Object (also: #delete!)
- #find(options = {}) ⇒ Object (also: #all)
- #find_one(options = {}) ⇒ Object (also: #one, #first)
-
#find_options(options) ⇒ Object
Set the default find options for this entity.
- #load(pk) ⇒ Object (also: #[])
-
#order(order_str) ⇒ Object
Set the default order option for this entity.
- #primary_key ⇒ Object
- #transaction(&block) ⇒ Object
- #update_properties(set, options = nil) ⇒ Object (also: #pupdate, #update_property, #batch_update)
Instance Method Details
#const_missing(sym) ⇒ Object
110 111 112 |
# File 'lib/og/entity.rb', line 110 def const_missing(sym) return sym end |
#count(options = {}) ⇒ Object
89 90 91 92 |
# File 'lib/og/entity.rb', line 89 def count( = {}) [:class] = self ogmanager.store.count() end |
#create(*args) {|obj| ... } ⇒ Object
54 55 56 57 58 59 |
# File 'lib/og/entity.rb', line 54 def create(*args) obj = self.new(*args) yield(obj) if block_given? ogmanager.store.save(obj) return obj end |
#delete(obj_or_pk) ⇒ Object Also known as: delete!
94 95 96 |
# File 'lib/og/entity.rb', line 94 def delete(obj_or_pk) ogmanager.store.delete(obj_or_pk, self) end |
#find(options = {}) ⇒ Object Also known as: all
73 74 75 76 77 78 79 |
# File 'lib/og/entity.rb', line 73 def find( = {}) if = self.[:find_options] = .first.update() end [:class] = self ogmanager.store.find() end |
#find_one(options = {}) ⇒ Object Also known as: one, first
82 83 84 85 |
# File 'lib/og/entity.rb', line 82 def find_one( = {}) [:class] = self ogmanager.store.find_one() end |
#find_options(options) ⇒ Object
Set the default find options for this entity.
116 117 118 |
# File 'lib/og/entity.rb', line 116 def () :find_options, end |
#load(pk) ⇒ Object Also known as: []
61 62 63 |
# File 'lib/og/entity.rb', line 61 def load(pk) ogmanager.store.load(pk, self) end |
#order(order_str) ⇒ Object
Set the default order option for this entity.
122 123 124 |
# File 'lib/og/entity.rb', line 122 def order(order_str) :find_options, :order => order_str end |
#primary_key ⇒ Object
103 104 105 106 107 108 |
# File 'lib/og/entity.rb', line 103 def primary_key unless @__meta and @__meta[:primary_key] self. :primary_key, Entity.resolve_primary_key(self) end @__meta[:primary_key].flatten end |
#transaction(&block) ⇒ Object
99 100 101 |
# File 'lib/og/entity.rb', line 99 def transaction(&block) ogmanager.store.transaction(&block) end |
#update_properties(set, options = nil) ⇒ Object Also known as: pupdate, update_property, batch_update
66 67 68 |
# File 'lib/og/entity.rb', line 66 def update_properties(set, = nil) ogmanager.store.update_properties(self, set, ) end |