Class: Mirage::Templates
- Inherits:
-
Object
- Object
- Mirage::Templates
- Includes:
- HTTParty
- Defined in:
- lib/mirage/client/templates.rb
Instance Method Summary collapse
- #default_config(&block) ⇒ Object
- #delete_all ⇒ Object
-
#initialize(base_url) ⇒ Templates
constructor
A new instance of Templates.
- #put(*args, &block) ⇒ Object
Constructor Details
Instance Method Details
#default_config(&block) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/mirage/client/templates.rb', line 11 def default_config &block return @default_config unless block_given? calling_instance = eval "self", block.binding @default_config.caller_binding = calling_instance @default_config.instance_eval &block @default_config.caller_binding = nil end |
#delete_all ⇒ Object
19 20 21 22 |
# File 'lib/mirage/client/templates.rb', line 19 def delete_all self.class.delete(@url) @requests.delete_all end |
#put(*args, &block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/mirage/client/templates.rb', line 24 def put *args, &block if args.first.class.is_a?(Template::Model) template = args.first template = template.clone template.endpoint "#{@url}/#{template.endpoint}" else endpoint, template = args if template.class.is_a?(Template::Model) template = template.clone template.endpoint "#{@url}/#{endpoint}" else template = Mirage::Template.new("#{@url}/#{endpoint}", template, @default_config) end end if block calling_instance = eval "self", block.binding template.caller_binding = calling_instance template.instance_exec(template, &block) template.caller_binding = nil end template.create end |