module Mirage::Template::Model::InstanceMethods
Attributes
caller_binding[RW]
Public Class Methods
new(*args)
click to toggle source
# File lib/mirage/client/template/model/instance_methods.rb, line 10 def initialize *args if args.last.is_a?(Template::Configuration) default_config = args.delete_at(-1) else default_config = Template::Configuration.new end @endpoint, @body = *args @content_type = default_config.content_type @http_method = default_config.http_method @status = default_config.status @delay = default_config.delay @required_parameters = {} @required_headers = {} @required_body_content = [] @headers = {} @default = default_config.default end
Public Instance Methods
create()
click to toggle source
# File lib/mirage/client/template/model/instance_methods.rb, line 34 def create @id = self.class.put("#{@endpoint}", :body => self.to_json, :headers => {'content-type' => 'application/json'})['id'] self end
delete()
click to toggle source
# File lib/mirage/client/template/model/instance_methods.rb, line 39 def delete self.class.delete(url) Request.delete requests_url end
encode(value)
click to toggle source
# File lib/mirage/client/template/model/instance_methods.rb, line 78 def encode(value) value.is_a?(Regexp) ? "%r{#{value.source}}" : value end
encode_regexs(hash_or_array)
click to toggle source
# File lib/mirage/client/template/model/instance_methods.rb, line 65 def encode_regexs hash_or_array case hash_or_array when Array hash_or_array.collect { |value| encode(value) } else encoded = {} hash_or_array.each do |key, value| encoded[key] = encode(value) end encoded end end
method_missing(method, *args, &block)
click to toggle source
Calls superclass method
# File lib/mirage/client/template/model/instance_methods.rb, line 82 def method_missing(method, *args, &block) if @caller_binding @caller_binding.send method, *args, &block else super method, *args, &block end end
to_json()
click to toggle source
# File lib/mirage/client/template/model/instance_methods.rb, line 45 def to_json { :response => { :body => Base64.encode64(body), :status => status, :default => default, :content_type => content_type, :headers => headers, :delay => delay }, :request => { :parameters => encode_regexs(required_parameters), :headers => encode_regexs(required_headers), :body_content => encode_regexs(required_body_content), :http_method => http_method, } }.to_json end