Class: MicroQ::Proxy::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/micro_q/proxies/base.rb

Direct Known Subclasses

ActionMailer, Class, Instance

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



6
7
8
9
10
11
# File 'lib/micro_q/proxies/base.rb', line 6

def initialize(options={})
  @errors  = []
  @options = options

  parse_and_validate
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/micro_q/proxies/base.rb', line 17

def method_missing(meth, *args)
  @method = meth.to_s
  @args = args

  defaults = [{
    :class => klass,
    :method => method,
    :args => args
  }.merge(@options)]

  defaults << { :when => at } if at

  MicroQ.push(*defaults)
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



4
5
6
# File 'lib/micro_q/proxies/base.rb', line 4

def args
  @args
end

#atObject (readonly)

Returns the value of attribute at.



4
5
6
# File 'lib/micro_q/proxies/base.rb', line 4

def at
  @at
end

#errorsObject (readonly)

Returns the value of attribute errors.



4
5
6
# File 'lib/micro_q/proxies/base.rb', line 4

def errors
  @errors
end

#klassObject (readonly)

Returns the value of attribute klass.



4
5
6
# File 'lib/micro_q/proxies/base.rb', line 4

def klass
  @klass
end

#methodObject (readonly)

Returns the value of attribute method.



4
5
6
# File 'lib/micro_q/proxies/base.rb', line 4

def method
  @method
end

Instance Method Details

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/micro_q/proxies/base.rb', line 32

def respond_to?(method)
  super || klass.respond_to?(method)
end

#valid?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/micro_q/proxies/base.rb', line 13

def valid?
  errors.empty?
end