Class: Restfulie::Client::Mikyung::Core
- Inherits:
-
Object
- Object
- Restfulie::Client::Mikyung::Core
- Defined in:
- lib/restfulie/client/mikyung/core.rb
Overview
iterates following a series of steps provided a goal and a starting uri.
Restfulie::Client::Mikyung.achieve(objective).at(uri).run
In order to implement your own walker, supply an object that respond to the move method. Check the run method code.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#accepts(accepts) ⇒ Object
readonly
Returns the value of attribute accepts.
-
#follow ⇒ Object
readonly
Returns the value of attribute follow.
-
#goal ⇒ Object
readonly
Returns the value of attribute goal.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
-
#walker ⇒ Object
readonly
Returns the value of attribute walker.
Instance Method Summary collapse
-
#achieve(goal) ⇒ Object
initializes with a goal in mind.
- #at(start) ⇒ Object
-
#initialize ⇒ Core
constructor
A new instance of Core.
-
#run ⇒ Object
keeps changing from a steady state to another until its goal has been achieved.
- #walks_with(walker) ⇒ Object
Constructor Details
#initialize ⇒ Core
Returns a new instance of Core.
13 14 15 |
# File 'lib/restfulie/client/mikyung/core.rb', line 13 def initialize @walker = Restfulie::Client::Mikyung::SteadyStateWalker.new end |
Instance Attribute Details
#accepts(accepts) ⇒ Object (readonly)
Returns the value of attribute accepts.
11 12 13 |
# File 'lib/restfulie/client/mikyung/core.rb', line 11 def accepts @accepts end |
#follow ⇒ Object (readonly)
Returns the value of attribute follow.
11 12 13 |
# File 'lib/restfulie/client/mikyung/core.rb', line 11 def follow @follow end |
#goal ⇒ Object (readonly)
Returns the value of attribute goal.
11 12 13 |
# File 'lib/restfulie/client/mikyung/core.rb', line 11 def goal @goal end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
11 12 13 |
# File 'lib/restfulie/client/mikyung/core.rb', line 11 def start @start end |
#walker ⇒ Object (readonly)
Returns the value of attribute walker.
11 12 13 |
# File 'lib/restfulie/client/mikyung/core.rb', line 11 def walker @walker end |
Instance Method Details
#achieve(goal) ⇒ Object
initializes with a goal in mind
23 24 25 26 |
# File 'lib/restfulie/client/mikyung/core.rb', line 23 def achieve(goal) @goal = goal self end |
#at(start) ⇒ Object
28 29 30 31 |
# File 'lib/restfulie/client/mikyung/core.rb', line 28 def at(start) @start = start self end |
#run ⇒ Object
keeps changing from a steady state to another until its goal has been achieved
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/restfulie/client/mikyung/core.rb', line 44 def run # load the steps and scenario @goal.steps @goal.scenario if @start.kind_of? String client = Restfulie.at(@start) client = client.follow if @follow client = client.accepts(@accepts) if @accepts @start = current = client.get else # probably configured thru the Rest Process Model class @start = current = @goal.class.get_restfulie.get end while(!@goal.completed?(current)) current = @walker.move(@goal, current, self) end current end |
#walks_with(walker) ⇒ Object
17 18 19 20 |
# File 'lib/restfulie/client/mikyung/core.rb', line 17 def walks_with(walker) @walker = walker self end |