class WorkflowToHash::Workflow
Attributes
workflow[R]
Public Class Methods
for(workflow)
click to toggle source
# File lib/workflow_to_hash/workflow.rb, line 4 def self.for(workflow) new(workflow).send(:to_hash) end
new(workflow)
click to toggle source
# File lib/workflow_to_hash/workflow.rb, line 10 def initialize(workflow) raise_unknown_workflow_error unless is_public_method?(workflow) @workflow = send workflow end
Private Instance Methods
is_public_method?(name)
click to toggle source
# File lib/workflow_to_hash/workflow.rb, line 28 def is_public_method?(name) public_methods.include?(name.to_sym) end
make_hash(array)
click to toggle source
Converts [:a, :b, :c] into {:a => :b, :b => :c}
# File lib/workflow_to_hash/workflow.rb, line 21 def make_hash(array) all_but_last = array[0..-2] all_but_first = array[1..-1] pairs = [all_but_last, all_but_first].transpose Hash[pairs] end
raise_unknown_workflow_error()
click to toggle source
# File lib/workflow_to_hash/workflow.rb, line 32 def raise_unknown_workflow_error raise UnknownWorkflowError.new 'Workflow name must match a public method' end
to_hash()
click to toggle source
# File lib/workflow_to_hash/workflow.rb, line 15 def to_hash make_hash workflow end