module Croesus::ModFactory

Mysteries abound, dynamic box of factory creation for API resources.

Public Class Methods

new(name, mod = Module.new) click to toggle source
# File lib/croesus/dsl/mod_factory.rb, line 40
def initialize(name, mod = Module.new)
  @mod = mod
  @name = name
  Croesus::AnonoMod.register(name, @mod)
  assemble_module
  @mod
end

Public Instance Methods

add_description(description) click to toggle source

Sets the description the Delphix Resource.

@param [String] description

the description of the API resource

@return [Nil]

@api public

# File lib/croesus/dsl/mod_factory.rb, line 56
def add_description(description)
  @mod.instance_variable_set(:@description, description)
  @mod.define_singleton_method(:description) { @description }
end
add_method(dsl_object) click to toggle source
# File lib/croesus/dsl/mod_factory.rb, line 74
def add_method(dsl_object)
  raw = dsl_object.to_hash
  name = raw[:name]
  verb = raw[:verb]
  @mod.methods[name] = raw[:description]
  @mod.singleton_class.send(:alias_method, name, "api_#{verb.downcase}")
  define_help
end
add_root_endpoint(root) click to toggle source

Sets the root endpoint for the resource.

@param [String] root

the root endpoint for the resource

@return [Nil]

@api public

# File lib/croesus/dsl/mod_factory.rb, line 69
def add_root_endpoint(root)
  @mod.instance_variable_set(:@root, root)
  @mod.define_singleton_method(:root) { @root }
end