Sha256: 8d3e846af5ee336921b8a57fd06f9cfa8dd3bd30eafc59c5bb2ca9178300de0f

Contents?: true

Size: 813 Bytes

Versions: 5

Compression:

Stored size: 813 Bytes

Contents

module Mirage
  class Templates
    include HTTParty
    def initialize base_url
      @url = "#{base_url}/templates"
      @requests = Requests.new(base_url)
      @default_config = Template::Configuration.new
    end

    def default_config &block
      return @default_config unless block_given?
      yield @default_config
    end

    def delete_all
      self.class.delete(@url)
      @requests.delete_all
    end

    def put *args, &block
      if args.first.class.is_a?(Template::Model)
        template = args.first
        template.endpoint "#{@url}/#{template.endpoint}"
      else
        endpoint, response = args
        template = Mirage::Template.new  "#{@url}/#{endpoint}", response, @default_config
      end
      template.instance_eval &block if block
      template.create
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mirage-3.0.0.alpha.9 lib/mirage/client/templates.rb
mirage-3.0.0.alpha.8 lib/mirage/client/templates.rb
mirage-3.0.0.alpha.7 lib/mirage/client/templates.rb
mirage-3.0.0.alpha.6 lib/mirage/client/templates.rb
mirage-3.0.0.alpha.5 lib/mirage/client/templates.rb