Class: Mirage::Template

Inherits:
Object
  • Object
show all
Includes:
HTTParty, Model::CommonMethods, Model::InstanceMethods
Defined in:
lib/mirage/client/template.rb,
lib/mirage/client/template/model.rb,
lib/mirage/client/template/configuration.rb,
lib/mirage/client/template/model/common_methods.rb,
lib/mirage/client/template/model/instance_methods.rb

Defined Under Namespace

Modules: Model Classes: Configuration

Instance Attribute Summary

Attributes included from Model::InstanceMethods

#caller_binding

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers::MethodBuilder

#builder_methods

Methods included from Model::InstanceMethods

#create, #delete, #encode, #encode_regexs, #method_missing, #to_json

Constructor Details

#initialize(*args) ⇒ Template

Returns a new instance of Template.

Raises:

  • (ArgumentError)


48
49
50
51
52
53
54
# File 'lib/mirage/client/template.rb', line 48

def initialize *args
  endpoint = args.first

  raise ArgumentError, "You must specify a string endpoint as the first argument" unless endpoint && endpoint.is_a?(String)
  super *args

end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Mirage::Template::Model::InstanceMethods

Class Method Details

.backedup_getObject



18
# File 'lib/mirage/client/template.rb', line 18

alias_method :backedup_get, :get

.get(url) ⇒ Object

Raises:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/mirage/client/template.rb', line 20

def get url
  response = backedup_get(url, :format => :json)
  raise TemplateNotFound if response.code == 404
  response_hashie = Hashie::Mash.new response

  response_config = response_hashie.response
  request_config = response_hashie.request

  template = new(response_hashie.endpoint, Base64.decode64(response_config.body))

  template.id response_hashie.id
  template.default response_config['default']
  template.delay response_config.delay
  template.content_type response_config.content_type
  template.status response_config.status
  template.headers response_config.headers

  template.required_parameters request_config.parameters
  template.required_body_content request_config.body_content
  template.http_method request_config.http_method
  template.url url
  template.requests_url response_hashie.requests_url
  template.required_headers request_config.headers

  template
end