Sha256: 2362f1732db2052b383dcebacaf56684179ab054e7118997c89a24bd4f50c513
Contents?: true
Size: 1.05 KB
Versions: 13
Compression:
Stored size: 1.05 KB
Contents
# A conclusion to a step. # # Whenever a step rule matches, there are a series of conditions to be executed. module Restfulie module Client module Mikyung class ThenCondition attr_reader :description # creates a new result, based on this description def initialize(description) @description = description end # finds the rule for this result and executes it def execute(resource, goal, mikyung) goal.then_rules.each do |rule| if (matches = Regexp.new(rule[0]).match(@description)) return invoke_rule(rule[1], resource, matches, mikyung) end end nil end private def invoke_rule(rule, resource, matches, mikyung) case rule.arity when 1 rule.call(resource) when 2 rule.call(resource, matches) else rule.call(resource, matches, mikyung) end end end end end end
Version data entries
13 entries across 13 versions & 2 rubygems