Class: Restfulie::Client::Mikyung::Core

Inherits:
Object
  • Object
show all
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

Mikyung

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCore

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

#followObject (readonly)

Returns the value of attribute follow



11
12
13
# File 'lib/restfulie/client/mikyung/core.rb', line 11

def follow
  @follow
end

#goalObject (readonly)

Returns the value of attribute goal



11
12
13
# File 'lib/restfulie/client/mikyung/core.rb', line 11

def goal
  @goal
end

#startObject (readonly)

Returns the value of attribute start



11
12
13
# File 'lib/restfulie/client/mikyung/core.rb', line 11

def start
  @start
end

#walkerObject (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

#runObject

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