Class: Munna::Proxy::Base

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

Direct Known Subclasses

Delete, Write

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kclass, target, options = {}, &block) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
# File 'lib/munna/proxy/base.rb', line 9

def initialize(kclass, target, options={}, &block)
	@kclass = kclass
	@target = target
	@opts = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



15
16
17
# File 'lib/munna/proxy/base.rb', line 15

def method_missing(name, *args, &block)
	__perform__ Execute.new @target, {:name => name, :args => args, :block => block}
end

Class Method Details

.builder(kclass, target, options = {}, &block) ⇒ Object



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

def self.builder(kclass, target, options={}, &block)
	instance = new kclass, target, options, &block
	block.present? ? instance.__perform__(Execute.new target, block) : instance
end

Instance Method Details

#__perform__(execute) ⇒ Object



19
20
21
# File 'lib/munna/proxy/base.rb', line 19

def __perform__(execute)
	@kclass.new(@target, @opts, execute).send("perform_#{self.class.name.demodulize.downcase}")
end