Class: RubyYacht::Configuration::DSL

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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, #check_server_type, #create_object, #load_custom_attributes, #run

Constructor Details

#initializeDSL

This initializer creates an empty configuration DSL.



102
103
104
105
# File 'lib/ruby_yacht/dsl/configuration.rb', line 102

def initialize
  self.load_custom_attributes
  @hook_options = {}
end

Instance Attribute Details

#hook_optionsObject

The default options for the hooks we're defining in the current block.



138
139
140
# File 'lib/ruby_yacht/dsl/configuration.rb', line 138

def hook_options
  @hook_options
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 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.


150
151
152
153
154
155
# File 'lib/ruby_yacht/dsl/configuration.rb', line 150

def add_hooks(options = {}, &block)
  old_options = hook_options.dup
  self.hook_options = options
  block.call
  self.hook_options = old_options
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.


177
178
179
# File 'lib/ruby_yacht/dsl/configuration.rb', line 177

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.


165
166
167
# File 'lib/ruby_yacht/dsl/configuration.rb', line 165

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.


192
193
194
# File 'lib/ruby_yacht/dsl/configuration.rb', line 192

def during(event_type, &block)
  add_hook :during, event_type, &block
end

#hookObject

: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.



125
# File 'lib/ruby_yacht/dsl/configuration.rb', line 125

add_object_list :hook, RubyYacht::Hook::DSL

#projectObject

: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.



115
# File 'lib/ruby_yacht/dsl/configuration.rb', line 115

add_object_list :project, RubyYacht::Project::DSL

#server_typeObject

: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.



135
# File 'lib/ruby_yacht/dsl/configuration.rb', line 135

add_object_list :server_type, RubyYacht::ServerType::DSL