Class: Garner::Mixins::Mongoid::Identity

Inherits:
Object
  • Object
show all
Includes:
Cache::Binding
Defined in:
lib/garner/mixins/mongoid/identity.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Cache::Binding

#garner_cache_key, #invalidate_garner_caches, #invalidation_strategy, #key_strategy

Constructor Details

#initializeIdentity

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

#conditionsObject

Returns the value of attribute conditions.



7
8
9
# File 'lib/garner/mixins/mongoid/identity.rb', line 7

def conditions
  @conditions
end

#handleObject

Returns the value of attribute handle.



7
8
9
# File 'lib/garner/mixins/mongoid/identity.rb', line 7

def handle
  @handle
end

#klassObject

Returns the value of attribute klass.



7
8
9
# File 'lib/garner/mixins/mongoid/identity.rb', line 7

def klass
  @klass
end

#proxy_bindingMongoid::Document

Return an object that can act as a binding on this identity’s behalf.

Returns:



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.

Parameters:

  • klass (Class)

    A

  • handle (Object)

    A String, Fixnum, BSON::ObjectId, etc. identifying the object.

Returns:



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_sString

Stringize this identity for purposes of marshaling.

Returns:

  • (String)


39
40
41
# File 'lib/garner/mixins/mongoid/identity.rb', line 39

def to_s
  "#{self.class.name}/klass=#{klass},handle=#{handle}"
end