Class: ShafClient::HalForm

Inherits:
Form show all
Defined in:
lib/shaf_client/hal_form.rb

Constant Summary

Constants included from MimeTypes

MimeTypes::DEFAULT_ADAPTER, MimeTypes::MIME_TYPE_HAL, MimeTypes::MIME_TYPE_JSON

Instance Attribute Summary collapse

Attributes inherited from Resource

#headers, #http_status

Attributes inherited from BaseResource

#attributes, #curies, #embedded_resources, #links

Instance Method Summary collapse

Methods inherited from Form

#[], #[]=, #submit, #valid?, #values

Methods inherited from Resource

build, content_type, #destroy!, #get, #get_doc, #get_hal_form, #initialize, #inspect, profile, #reload!

Methods inherited from BaseResource

#[], #actions, #attribute, #curie, #embedded, #initialize, #inspect, #link, #rel?, #to_h, #to_s

Constructor Details

This class inherits a constructor from ShafClient::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ShafClient::BaseResource

Instance Attribute Details

#targetObject

Returns the value of attribute target.



5
6
7
# File 'lib/shaf_client/hal_form.rb', line 5

def target
  @target
end

Instance Method Details

#content_typeObject



21
22
23
# File 'lib/shaf_client/hal_form.rb', line 21

def content_type
  template[:contentType] || 'application/json'
end

#fieldsObject



25
26
27
28
29
# File 'lib/shaf_client/hal_form.rb', line 25

def fields
  template[:properties].map do |values|
    Field.new(values.transform_keys(&:to_sym))
  end
end

#http_methodObject



17
18
19
# File 'lib/shaf_client/hal_form.rb', line 17

def http_method
  template[:method].downcase.to_sym
end

#nameObject



13
14
15
# File 'lib/shaf_client/hal_form.rb', line 13

def name
  attribute(:name)
end

#titleObject



9
10
11
# File 'lib/shaf_client/hal_form.rb', line 9

def title
  template[:title]
end