Class: RubyYacht::Configuration::DSL
- Inherits:
-
Object
- Object
- RubyYacht::Configuration::DSL
- Extended by:
- DSL::Base::ClassMethods
- Includes:
- DSL::Base
- Defined in:
- lib/ruby_yacht/dsl/configuration.rb
Overview
This method provides a DSL for top-level configuration.
Instance Attribute Summary collapse
-
#hook_folder ⇒ Object
The path for files and other resources from configuration hooks.
-
#hook_server_type ⇒ Object
The app type for hooks that we are defining in the current block.
Instance Method Summary collapse
-
#add_hooks(options = {}, &block) ⇒ Object
This method sets default attributes for a group of hooks.
-
#after(event_type, &block) ⇒ Object
This method adds an after hook.
-
#before(event_type, &block) ⇒ Object
This method adds a before hook.
-
#during(event_type, &block) ⇒ Object
This method adds a during hook.
-
#hook ⇒ Object
:method: hook.
-
#initialize ⇒ DSL
constructor
This initializer creates an empty configuration DSL.
-
#project ⇒ Object
:method: project.
-
#server_type ⇒ Object
:method: server_type.
Methods included from DSL::Base::ClassMethods
add_attribute, add_boolean, add_generic_attribute, add_list, add_object, add_object_list, all_attributes, copied_attributes, created_type, creates_object, custom_attribute_method, default_values, required_attributes
Methods included from DSL::Base
#check_required_attributes, #create_object, #load_custom_attributes, #run
Constructor Details
#initialize ⇒ DSL
This initializer creates an empty configuration DSL.
74 75 76 |
# File 'lib/ruby_yacht/dsl/configuration.rb', line 74 def initialize self.load_custom_attributes end |
Instance Attribute Details
#hook_folder ⇒ Object
The path for files and other resources from configuration hooks.
109 110 111 |
# File 'lib/ruby_yacht/dsl/configuration.rb', line 109 def hook_folder @hook_folder end |
#hook_server_type ⇒ Object
The app type for hooks that we are defining in the current block.
112 113 114 |
# File 'lib/ruby_yacht/dsl/configuration.rb', line 112 def hook_server_type @hook_server_type end |
Instance Method Details
#add_hooks(options = {}, &block) ⇒ Object
This method sets default attributes for a group of hooks.
Any hooks that you create in the associated block will have their script folder and app type specified by the attached properties.
### Parameters
-
**folder: String** The full path to the script folder.
-
block A block for adding the hooks.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/ruby_yacht/dsl/configuration.rb', line 123 def add_hooks( = {}, &block) keys = [:folder, :server_type] = {} keys.each do |key| [key] = self.send("hook_#{key}") self.send("hook_#{key}=", [key]) if .has_key?(key) end block.call keys.each do |key| self.send("hook_#{key}=", [key]) end end |
#after(event_type, &block) ⇒ Object
This method adds an after hook.
### Parameters
-
**event_type: Symbol** The event type for the new hook.
-
block A block for configuring the hook. You can
call the RubyYacht::Hook::DSL methods in this block.
158 159 160 |
# File 'lib/ruby_yacht/dsl/configuration.rb', line 158 def after(event_type, &block) add_hook :after, event_type, &block end |
#before(event_type, &block) ⇒ Object
This method adds a before hook.
### Parameters
-
**event_type: Symbol** The event type for the new hook.
-
block A block for configuring the hook. You can
call the RubyYacht::Hook::DSL methods in this block.
146 147 148 |
# File 'lib/ruby_yacht/dsl/configuration.rb', line 146 def before(event_type, &block) add_hook :before, event_type, &block end |
#during(event_type, &block) ⇒ Object
This method adds a during hook.
This hook will be run while event is happening, and provides the core logic for the event.
### Parameters
-
**event_type: Symbol** The event type for the new hook.
-
block A block for configuring the hook. You can
call the RubyYacht::Hook::DSL methods in this block.
173 174 175 |
# File 'lib/ruby_yacht/dsl/configuration.rb', line 173 def during(event_type, &block) add_hook :during, event_type, &block end |
#hook ⇒ Object
:method: hook
This method adds a hook to the configuration.
This takes hook’s event_time and event_type as its arguments. It also takes a block which you can use to configure the hook, using RubyYacht::Hook::DSL.
96 |
# File 'lib/ruby_yacht/dsl/configuration.rb', line 96 add_object_list :hook, RubyYacht::Hook::DSL |
#project ⇒ Object
:method: project
This method adds a project to the configuration.
This takes the project name as its first argument. It also takes a block which you can use to configure the project, using RubyYacht::Project::DSL.
86 |
# File 'lib/ruby_yacht/dsl/configuration.rb', line 86 add_object_list :project, RubyYacht::Project::DSL |
#server_type ⇒ Object
:method: server_type
This method adds a server type to the configuration.
This takes type’s name as its argument. It also takes a block which you can use to configure the type, using RubyYacht::ServerType::DSL.
106 |
# File 'lib/ruby_yacht/dsl/configuration.rb', line 106 add_object_list :server_type, RubyYacht::ServerType::DSL |