Class: VisitCounter::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/visit_counter_updater/key.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, method) ⇒ Key

Returns a new instance of Key.



5
6
7
8
# File 'lib/visit_counter_updater/key.rb', line 5

def initialize(object, method)
  @object = object
  @method = method
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



4
5
6
# File 'lib/visit_counter_updater/key.rb', line 4

def method
  @method
end

#objectObject (readonly)

Returns the value of attribute object.



4
5
6
# File 'lib/visit_counter_updater/key.rb', line 4

def object
  @object
end

Class Method Details

.generate(method, obj_class, obj_id = nil) ⇒ Object



10
11
12
# File 'lib/visit_counter_updater/key.rb', line 10

def self.generate(method, obj_class, obj_id = nil)
  ["visit_counter", obj_class, obj_id, method].compact.join("::")
end

Instance Method Details

#generate_from_instanceObject



14
15
16
17
# File 'lib/visit_counter_updater/key.rb', line 14

def generate_from_instance
  object_class = self.object_class
  Key.generate(method,object_class, self.object.id)
end

#object_classObject



19
20
21
# File 'lib/visit_counter_updater/key.rb', line 19

def object_class
  object.class.to_s
end