Class: Garner::Mixins::Mongoid::Identity
- Inherits:
-
Object
- Object
- Garner::Mixins::Mongoid::Identity
- Includes:
- Cache::Binding
- Defined in:
- lib/garner/mixins/mongoid/identity.rb
Instance Attribute Summary collapse
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#handle ⇒ Object
Returns the value of attribute handle.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#proxy_binding ⇒ Mongoid::Document
Return an object that can act as a binding on this identity’s behalf.
Class Method Summary collapse
-
.from_class_and_handle(klass, handle) ⇒ Garner::Mixins::Mongoid::Identity
Instantiate a new Mongoid::Identity.
Instance Method Summary collapse
-
#initialize ⇒ Identity
constructor
A new instance of Identity.
-
#to_s ⇒ String
Stringize this identity for purposes of marshaling.
Methods included from Cache::Binding
#garner_cache_key, #invalidate_garner_caches, #invalidation_strategy, #key_strategy
Constructor Details
#initialize ⇒ Identity
Returns a new instance of Identity.
25 26 27 |
# File 'lib/garner/mixins/mongoid/identity.rb', line 25 def initialize @conditions = {} end |
Instance Attribute Details
#conditions ⇒ Object
Returns the value of attribute conditions.
7 8 9 |
# File 'lib/garner/mixins/mongoid/identity.rb', line 7 def conditions @conditions end |
#handle ⇒ Object
Returns the value of attribute handle.
7 8 9 |
# File 'lib/garner/mixins/mongoid/identity.rb', line 7 def handle @handle end |
#klass ⇒ Object
Returns the value of attribute klass.
7 8 9 |
# File 'lib/garner/mixins/mongoid/identity.rb', line 7 def klass @klass end |
#proxy_binding ⇒ Mongoid::Document
Return an object that can act as a binding on this identity’s behalf.
32 33 34 |
# File 'lib/garner/mixins/mongoid/identity.rb', line 32 def proxy_binding @proxy_binding end |
Class Method Details
.from_class_and_handle(klass, handle) ⇒ Garner::Mixins::Mongoid::Identity
Instantiate a new Mongoid::Identity.
15 16 17 18 19 20 21 22 23 |
# File 'lib/garner/mixins/mongoid/identity.rb', line 15 def self.from_class_and_handle(klass, handle) validate_class!(klass) self.new.tap do |identity| identity.klass = klass identity.handle = handle identity.conditions = conditions_for(klass, handle) end end |
Instance Method Details
#to_s ⇒ String
Stringize this identity for purposes of marshaling.
39 40 41 |
# File 'lib/garner/mixins/mongoid/identity.rb', line 39 def to_s "#{self.class.name}/klass=#{klass},handle=#{handle}" end |