Class: Munna::Perform::ActiveRecord

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

Instance Method Summary collapse

Methods inherited from Base

#cached_key, #initialize, #perform_delete, #perform_write

Constructor Details

This class inherits a constructor from Munna::Perform::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/munna/perform/active_record.rb', line 16

def method_missing(name, *args, &block)
	if /^all$/ =~ name.to_s
		ActiveRecordMethod.new(@target).send(name)
	else
		super(name, *args, &block)
	end
end

Instance Method Details

#method_nameObject



8
9
10
# File 'lib/munna/perform/active_record.rb', line 8

def method_name
	[super, (send(@execute.name) rescue nil)].compact
end

#normalize(values) ⇒ Object



12
13
14
# File 'lib/munna/perform/active_record.rb', line 12

def normalize(values)
	values.is_a?(::ActiveRecord::Relation) ? values.to_a : values
end

#target_nameObject



4
5
6
# File 'lib/munna/perform/active_record.rb', line 4

def target_name
	@target.class == Class ? @target.table_name : @target.cache_key
end