Module: ConditionatorHooks::ClassLevelConditionator

Defined in:
lib/conditionator/hooks.rb

Instance Method Summary collapse

Instance Method Details

#dataObject



110
111
112
113
# File 'lib/conditionator/hooks.rb', line 110

def data
  @data = {} if @data.nil?
  @data 
end

#data=(value) ⇒ Object



114
115
116
# File 'lib/conditionator/hooks.rb', line 114

def data=(value)
  @data = value
end

#postcondition_for(method_name, conditions) ⇒ Object



131
132
133
134
135
136
137
138
139
# File 'lib/conditionator/hooks.rb', line 131

def postcondition_for method_name, conditions
  if method_name.is_a? Array
    method_name.each do |m|
      add_condition_for :post, m, conditions
    end
  else
    add_condition_for :post, method_name, conditions
  end
end

#precondition_for(method_name, preconditions, options = {}) ⇒ Object

Adds a precondition for the method ‘method_name’ method_name can be an array of methods, in which case, we add the same preconditions for all methos inside it.



121
122
123
124
125
126
127
128
129
# File 'lib/conditionator/hooks.rb', line 121

def precondition_for method_name, preconditions, options = {}
  if method_name.is_a? Array 
    method_name.each do |m| 
      add_condition_for :pre, m, preconditions, options
    end
  else
    add_condition_for :pre, method_name, preconditions, options
  end
end