Class: Velocity::Chico
- Defined in:
- lib/acceleration/velocity.rb
Overview
Chico is an AXL runner. It allows a user to try small snippets of AXL, the language Velocity uses to glue its parts together.
Warning: Velocity::Chico may move to Velocity::Instance::Chico in the future.
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
The content type to be sent.
Attributes inherited from Instance
#endpoint, #error, #open_timeout, #password, #read_timeout, #username, #v_app
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Chico
constructor
call-seq: new(:endpoint => endpoint, :username => username, :password => password).
-
#run(xml) ⇒ Object
call-seq: run(xml) run(:xml => xml).
-
#run_with(args = {}) ⇒ Object
call-seq: run_with(:xml => xml, …).
Methods inherited from Instance
#axl_service_status, #base_parameters, #call, #collection, #collections, #dictionaries, #ping, #query, #repository, #rest_call, #sanity_check, #write_environment_list
Constructor Details
#initialize(args = {}) ⇒ Chico
call-seq:
new(:endpoint => endpoint, :username => username, :password => password)
Create a new Chico instance. This wraps around Instance constructor and sets :v_app
to ‘chico’.
1302 1303 1304 1305 |
# File 'lib/acceleration/velocity.rb', line 1302 def initialize(args = {}) super(args.merge(v_app: 'chico')) @content_type = 'text/xml' end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
The content type to be sent. Default is text/xml.
1294 1295 1296 |
# File 'lib/acceleration/velocity.rb', line 1294 def content_type @content_type end |
Instance Method Details
#run(xml) ⇒ Object
call-seq:
run(xml)
run(:xml => xml)
Run an AXL snippet on Chico
Expects a String or a Hash with a key :xml
containing the AXL to be run.
1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 |
# File 'lib/acceleration/velocity.rb', line 1316 def run(xml) if !([String, Hash].member? xml.class) || xml.empty? raise ArgumentError, 'Need some AXL to process.' end if (xml.class == Hash) && xml.key?(:xml) h = xml elsif xml.class == String h = { xml: xml } end run_with h end |
#run_with(args = {}) ⇒ Object
call-seq:
run_with(:xml => xml, ...)
Run an XML snippet with more options, such as :profile
=> ‘profile’.
1335 1336 1337 1338 1339 1340 |
# File 'lib/acceleration/velocity.rb', line 1335 def run_with(args = {}) if args.nil? || !args.key?(:xml) || args[:xml].empty? raise ArgumentError, 'Need an :xml key containing some AXL to process.' end call nil, { content_type: @content_type, backend: 'backend' }.merge(args) end |