Module: Croesus::ModFactory
Overview
Mysteries abound, dynamic box of factory creation for API resources.
Instance Method Summary collapse
-
#add_description(description) ⇒ Nil
Sets the description the Delphix Resource.
- #add_method(dsl_object) ⇒ Object
-
#add_root_endpoint(root) ⇒ Nil
Sets the root endpoint for the resource.
- #initialize(name, mod = Module.new) ⇒ Object
Methods included from Utils
#callable, #caller_name, #camelize, #class_name, #classify, #command_in_path?, #demodulize, #pluralize, #request_id, #retrier, #singularize, #terminal_dimensions, #twenty_four_hours_ago, #underscore, #utc_httpdate, #verify_options
Instance Method Details
#add_description(description) ⇒ Nil
Sets the description the Delphix Resource.
56 57 58 59 |
# 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) ⇒ Object
74 75 76 77 78 79 80 81 |
# 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) ⇒ Nil
Sets the root endpoint for the resource.
69 70 71 72 |
# 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 |
#initialize(name, mod = Module.new) ⇒ Object
40 41 42 43 44 45 46 |
# 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 |