Class: Munna::Perform::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/munna/perform/base.rb

Direct Known Subclasses

ActiveRecord, Object

Instance Method Summary collapse

Constructor Details

#initialize(target, opts, execute) ⇒ Base

Returns a new instance of Base.



4
5
6
7
8
# File 'lib/munna/perform/base.rb', line 4

def initialize(target, opts, execute)
	@target = target
	@opts = opts
	@execute = execute
end

Instance Method Details

#cached_keyObject



21
22
23
# File 'lib/munna/perform/base.rb', line 21

def cached_key
	@cached_key ||= Munna.get_key [target_name, method_name]
end

#method_nameObject



25
26
27
# File 'lib/munna/perform/base.rb', line 25

def method_name
	@opts[:key] || @execute.name || @opts[:caller_name]
end

#normalize(value) ⇒ Object



29
30
31
# File 'lib/munna/perform/base.rb', line 29

def normalize(value)
	value
end

#perform_deleteObject



17
18
19
# File 'lib/munna/perform/base.rb', line 17

def perform_delete
	Munna.cache.delete cached_key
end

#perform_writeObject



10
11
12
13
14
15
# File 'lib/munna/perform/base.rb', line 10

def perform_write
	Munna.cache.write cached_key
	Rails.cache.fetch(cached_key, @opts) do
		normalize(@execute.value)
	end
end