Class: Ocelot::ScriptFilter

Inherits:
Rules::Filter show all
Defined in:
lib/ocelot/dsl.rb

Instance Method Summary collapse

Methods inherited from Rules::Filter

#filter

Methods inherited from Base

#connection, #in?, #logger, #obj_to_s, #remove_callbacks, #safely

Constructor Details

#initialize(p) ⇒ ScriptFilter

Returns a new instance of ScriptFilter.



106
107
108
# File 'lib/ocelot/dsl.rb', line 106

def initialize(p)
  @p = p
end

Instance Method Details

#defaultObject



126
127
128
# File 'lib/ocelot/dsl.rb', line 126

def default
  @result = old_load @obj, @collection, @name 
end

#load(obj, collection, name) ⇒ Object



110
111
112
113
114
115
116
# File 'lib/ocelot/dsl.rb', line 110

def load(obj, collection, name)
  @obj, @collection, @name = obj, collection, name

  @result = nil
  instance_exec(obj, collection, name, &@p)
  @result || default
end

#nothingObject



118
119
120
# File 'lib/ocelot/dsl.rb', line 118

def nothing
  @result = []
end

#old_loadObject



105
# File 'lib/ocelot/dsl.rb', line 105

alias :old_load :load

#result(val) ⇒ Object



122
123
124
# File 'lib/ocelot/dsl.rb', line 122

def result(val)
  @result = val
end