Class: Vop::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/vop/objects/filter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plugin, name) ⇒ Filter

Returns a new instance of Filter.



10
11
12
13
# File 'lib/vop/objects/filter.rb', line 10

def initialize(plugin, name)
  @plugin = plugin
  @name = name
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



8
9
10
# File 'lib/vop/objects/filter.rb', line 8

def block
  @block
end

#descriptionObject

Returns the value of attribute description.



7
8
9
# File 'lib/vop/objects/filter.rb', line 7

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/vop/objects/filter.rb', line 5

def name
  @name
end

#pluginObject (readonly)

Returns the value of attribute plugin.



5
6
7
# File 'lib/vop/objects/filter.rb', line 5

def plugin
  @plugin
end

Instance Method Details

#execute(request) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/vop/objects/filter.rb', line 19

def execute(request)
  # this executor is just to prepare payload
  ex = Executor.new(@plugin.op)
  context = {}
  block_param_names = self.block.parameters.map { |x| x.last }
  payload = ex.prepare_payload(request, context, block_param_names)

  response = nil
  begin
    response = self.block.call(*payload)
  rescue InterruptChain => ic
    response = ic.response
  end

  response
end

#short_nameObject



15
16
17
# File 'lib/vop/objects/filter.rb', line 15

def short_name
  @name.split(".").last
end