Sha256: ed63e6ea0f6941e682dae31c972b2d05794848a187b4d4ca47d57b39f457479d
Contents?: true
Size: 835 Bytes
Versions: 1
Compression:
Stored size: 835 Bytes
Contents
# A conclusion to a step. # # Whenever a step rule matches, there are a series of conditions to be executed. class Restfulie::Client::Mikyung::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) if rule.arity==1 rule.call(resource) elsif rule.arity==2 rule.call(resource, matches) else rule.call(resource, matches, mikyung) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
restfulie-0.8.0 | lib/restfulie/client/mikyung/then_condition.rb |