Class: ApiVersions::DSL
- Inherits:
-
Object
- Object
- ApiVersions::DSL
- Extended by:
- Forwardable
- Defined in:
- lib/api-versions/dsl.rb
Instance Method Summary collapse
- #cache(options, &block) ⇒ Object
- #inherit(options) ⇒ Object
-
#initialize(context, &block) ⇒ DSL
constructor
A new instance of DSL.
- #version(version_number, &block) ⇒ Object
Constructor Details
#initialize(context, &block) ⇒ DSL
Returns a new instance of DSL.
7 8 9 10 11 |
# File 'lib/api-versions/dsl.rb', line 7 def initialize(context, &block) @context = context singleton_class.def_delegators :@context, *(@context.public_methods - public_methods) instance_eval(&block) end |
Instance Method Details
#cache(options, &block) ⇒ Object
27 28 29 30 31 |
# File 'lib/api-versions/dsl.rb', line 27 def cache(, &block) @resource_cache ||= {} @resource_cache[[:as]] = block yield end |
#inherit(options) ⇒ Object
21 22 23 24 25 |
# File 'lib/api-versions/dsl.rb', line 21 def inherit() Array.wrap([:from]).each do |block| @resource_cache[block].call end end |
#version(version_number, &block) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/api-versions/dsl.rb', line 13 def version(version_number, &block) VersionCheck.default_version ||= version_number constraints VersionCheck.new(version: version_number) do scope({ module: "v#{version_number}" }, &block) end end |