Class: SERVICE_CLASS_NAME::ACTION_CLASS_NAME
- Inherits:
-
Curbala::Action
- Object
- Curbala::Action
- SERVICE_CLASS_NAME::ACTION_CLASS_NAME
- Defined in:
- lib/generators/curbala/action/template/action.rb
Instance Method Summary collapse
Instance Method Details
#action_url_segment ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/generators/curbala/action/template/action.rb', line 3 def action_url_segment # if this is a GET index, GET new or POST create action, probably blank. # for update, show, edit, delete, express id however service expects it (in URL or possibly in payload) # * data written/specified in this string must be appropriately url-encoded "construct action segment of SERVICE_CLASS_NAME ACTION_CLASS_NAME url in action_url_segment() method at #{__FILE__}:#{__LINE__}" end |
#invoke_action ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/generators/curbala/action/template/action.rb', line 12 def invoke_action # this is where arguments from @args_hash are transformed into url parameters or request payload. # - see Curbala::Action.xml_payload_from_args_hash() # the proper http method is invoked # can set action-specific curl options: # curl.timeout = 300 # set_payload # see Curbala::Action.set_payload() # xml_request # see Curbala::Action.xml_request() # some examples: # curl.http_get # curl.http_post(Curl::PostField.content(:name, args_hash[:name])) # curl.http_put(Curl::PostField.content(:_arg, args_hash[:_arg])) # curl.http_delete # APIs have different formatting/hygiene/unpacking needs... # curbala is xml/json agnostic and does not induce any xml/json library bloat # pull in whatever you need to correctly format your request data (REXML, Nokogiri, JSON) from args_hash data # recommend an intermediate class for actions that are constructed and/or unpacked in a similar way # some half-hearted support is provided. # see xml_request(), xml_payload(xml) and xml_payload_from_args_hash(root) methods. send("implement invoke_action() method in #{__FILE__}:12") end |