Module: Mirage::Template::Model

Defined in:
lib/mirage/client/template/model.rb,
lib/mirage/client/template/model/common_methods.rb,
lib/mirage/client/template/model/instance_methods.rb

Defined Under Namespace

Modules: CommonMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.extended(clazz) ⇒ Object



10
11
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
39
40
41
42
43
# File 'lib/mirage/client/template/model.rb', line 10

def extended clazz
  clazz.extend(CommonMethods)
  clazz.extend(Helpers::MethodBuilder)
  clazz.send(:include, HTTParty)
  clazz.send(:include, CommonMethods)
  clazz.send(:include, InstanceMethods)


  mod = Module.new do
    def initialize *args

      super *args
      [:content_type,
       :http_method,
       :default,
       :status,
       :delay,
       :required_parameters,
       :required_body_content,
       :required_headers,
       :headers,
       :endpoint, :delay].each do |attribute|
        eval("#{attribute} self.class.#{attribute} if self.class.#{attribute}")
      end


    end
  end

  clazz.send(:include, mod)

  clazz.format :json
  clazz
end