Class: ShafClient::Form
Instance Attribute Summary
Attributes inherited from Resource
#headers, #http_status
Attributes inherited from BaseResource
#attributes, #curies, #embedded_resources, #links
Instance Method Summary
collapse
Methods inherited from Resource
#get_doc, #initialize
#actions, #attribute, #curie, #embedded, #initialize, #link, #to_h, #to_s
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class ShafClient::BaseResource
Instance Method Details
#[](key) ⇒ Object
15
16
17
|
# File 'lib/shaf_client/form.rb', line 15
def [](key)
values[key]
end
|
#[]=(key, value) ⇒ Object
19
20
21
|
# File 'lib/shaf_client/form.rb', line 19
def []=(key, value)
values[key] = value
end
|
#http_method ⇒ Object
27
28
29
|
# File 'lib/shaf_client/form.rb', line 27
def http_method
attribute(:method).downcase.to_sym
end
|
#reload! ⇒ Object
37
38
39
|
# File 'lib/shaf_client/form.rb', line 37
def reload!
self << get_form(:self, skip_cache: true)
end
|
#submit ⇒ Object
33
34
35
|
# File 'lib/shaf_client/form.rb', line 33
def submit
client.send(http_method, target, payload: @values)
end
|
#target ⇒ Object
23
24
25
|
# File 'lib/shaf_client/form.rb', line 23
def target
attribute(:href)
end
|
#values ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/shaf_client/form.rb', line 7
def values
return @values if defined? @values
@values = attribute(:fields).each_with_object({}) do |d, v|
v[d['name'].to_sym] = d['value']
end
end
|