class RubyYacht::Configuration::DSL
This method provides a DSL
for top-level configuration.
Attributes
The default options for the hooks we’re defining in the current block.
The configuration that has been loaded from a local YAML file.
Public Class Methods
This initializer creates an empty configuration DSL
.
# File lib/ruby_yacht/dsl/configuration.rb, line 107 def initialize self.load_custom_attributes @hook_options = {} @local_config = {} end
Public Instance Methods
This method sets default attributes for a group of hooks.
Any hooks that you create in the associated block will have the included options set on them automatically. You will also be able to override these options in the configuration blocks for individual hooks.
### Parameters
-
**options: Hash** The fields to set on the hooks.
-
block A block for adding the hooks.
# File lib/ruby_yacht/dsl/configuration.rb, line 159 def add_hooks(options = {}, &block) old_options = hook_options.dup self.hook_options = options block.call self.hook_options = old_options end
This method loads config from a local YAML file.
The contents of the file will be stored in the global configuration’s ‘local_config` field. From there, it can be loaded into another DSL
object by calling `copy_local_config`.
### Parameters
-
**path: String** The full path to the config file.
# File lib/ruby_yacht/dsl/configuration.rb, line 175 def add_local_config(path) new_config = YAML.load_file(path) @local_config = @local_config.merge(new_config) end
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.
# File lib/ruby_yacht/dsl/configuration.rb, line 200 def after(event_type, &block) add_hook :after, event_type, &block end
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.
# File lib/ruby_yacht/dsl/configuration.rb, line 188 def before(event_type, &block) add_hook :before, event_type, &block end
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.
# File lib/ruby_yacht/dsl/configuration.rb, line 215 def during(event_type, &block) add_hook :during, event_type, &block end
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
.
# File lib/ruby_yacht/dsl/configuration.rb, line 131 add_object_list :hook, RubyYacht::Hook::DSL
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
.
# File lib/ruby_yacht/dsl/configuration.rb, line 121 add_object_list :project, RubyYacht::Project::DSL
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
.
# File lib/ruby_yacht/dsl/configuration.rb, line 141 add_object_list :server_type, RubyYacht::ServerType::DSL
Private Instance Methods
# File lib/ruby_yacht/dsl/configuration.rb, line 223 def add_hook(event_time, event_type, &block) hook_options = self.hook_options hook event_time, event_type do hook_options.each do |key, value| public_send(key, value) end instance_eval(&block) end end