Module: ButlerMainframe

Extended by:
ButlerMainframe
Included in:
ButlerMainframe
Defined in:
lib/mainframe/emulators/pcomm.rb,
lib/butler-mainframe.rb,
lib/core/configuration.rb,
lib/mainframe/host_base.rb,
lib/mainframe/emulators/x3270.rb,
lib/core/configuration_dynamic.rb,
lib/generators/butler_mainframe.rb,
lib/mainframe/emulators/passport.rb,
lib/mainframe/customization/active_record.rb,
lib/mainframe/customization/generic_functions.rb,
lib/generators/butler/templates/custom_functions.rb

Overview

These modules contain extensions for the Host class

Defined Under Namespace

Modules: ActiveRecord, Base, CustomFunctions, GenericFunctions, Settings Classes: Configuration, Host, HostBase

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.configurationObject



20
21
22
# File 'lib/core/configuration.rb', line 20

def self.configuration
  @configuration ||= Configuration.new
end

.configuration=(config) ⇒ Object



24
25
26
# File 'lib/core/configuration.rb', line 24

def self.configuration=(config)
  @configuration = config
end

.configure {|configuration| ... } ⇒ Object

Yields:



28
29
30
# File 'lib/core/configuration.rb', line 28

def self.configure
  yield configuration
end

.rootObject



13
14
15
# File 'lib/butler-mainframe.rb', line 13

def self.root
  File.expand_path('../..', __FILE__)
end

Instance Method Details

#configure_on_the_fly(&block) ⇒ Object

And we define a wrapper for the configuration block, that we’ll use to set up our set of options



29
30
31
# File 'lib/core/configuration_dynamic.rb', line 29

def configure_on_the_fly(&block)
  instance_eval &block
end

#parameter(*names) ⇒ Object

Appdata provides a basic single-method DSL with .parameter method being used to define a set of available settings. This method takes one or more symbols, with each one being a name of the configuration option.



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/core/configuration_dynamic.rb', line 13

def parameter(*names)
  names.each do |name|
    attr_accessor name

    # For each given symbol we generate accessor method that sets option's
    # value being called with an argument, or returns option's current value
    # when called without arguments
    define_method name do |*values|
      value = values.first
      value ? self.send("#{name}=", value) : instance_variable_get("@#{name}")
    end
  end
end