Sha256: 9b661eff496c19f2324653205794dcca804dba28a745646e02904f80d0aa6923
Contents?: true
Size: 1.61 KB
Versions: 3
Compression:
Stored size: 1.61 KB
Contents
# encoding: utf-8 require 'hyperdrive/dsl/resource' module Hyperdrive module DSL include Values extend self attr_reader :config, :resources def instance @config ||= default_config.dup @resources ||= {} self end def instrument(*args) @config[:instrumenter] = @config[:instrumenter] || Hyperdrive::Instrumenters::Noop @config[:instrumenter].instrument(*args) end private def name(name) @config[:name] = name end def description(description) @config[:description] = description end def vendor(vendor) @config[:vendor] = vendor end def media_types(media_types) @config[:media_types] = media_types end def cors(options = {}) allowed_options = default_cors_options.keys options = Utils.sanitize_keys(allowed_options, options) @config[:cors] = config[:cors].merge(options) end def per_page(per_page) per_page = per_page.to_i per_page = default_config[:per_page] if per_page == 0 @config[:per_page] = per_page end def ssl(force_ssl) @config[:ssl] = force_ssl end def instrumenter(instrumenter) @config[:instrumenter] = instrumenter || Hyperdrive::Instrumenters::Noop end def resource(name) @resources[name] = Resource.new(name, @config, &Proc.new).resource end def reset! # not terribly useful outside of a test environment :( @config = default_config.dup @resources = {} end end end def hyperdrive(&block) Hyperdrive::DSL.instance.instance_eval(&block) if block_given? Hyperdrive::DSL.instance end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hyperdrive-0.0.18 | lib/hyperdrive/dsl.rb |
hyperdrive-0.0.17 | lib/hyperdrive/dsl.rb |
hyperdrive-0.0.16 | lib/hyperdrive/dsl.rb |