-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransition.rb
35 lines (30 loc) · 963 Bytes
/
transition.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'representor/transition_builder'
class Representor
##
# A canonical transition for introspecting a state transition in a resource.
class Transition
attr_reader :relation_type, :uri, :title, :description
def initialize(relation_type, uri, options = {})
@relation_type, @uri = relation_type, uri
@title = options[:title]
@description = options[:description]
@transition_builder = TransitionBuilder.new
yield @transition_builder if block_given?
@internal_struct = @transition_builder.to_struct
end
##
# The input attributes building a body to submit with the transition.
#
# @return [Hash of InputProperty]
def attributes
@attributes ||= @internal_struct[:attributes]
end
##
# The input query parameters for the transition URI.
#
# @return [Hash of InputProperty]
def parameters
@attributes ||= @internal_struct[:parameters]
end
end
end