Module: PoiseLanguages::Command::Mixin::Resource::ClassMethods

Included in:
PoiseLanguages::Command::Mixin::Resource
Defined in:
lib/poise_languages/command/mixin.rb

Overview

Since:

  • 1.0.0

Instance Method Summary collapse

Instance Method Details

#language_command_default_binary(val = Poise::NOT_PASSED) ⇒ Object

Since:

  • 1.0.0



146
147
148
149
# File 'lib/poise_languages/command/mixin.rb', line 146

def language_command_default_binary(val=Poise::NOT_PASSED)
  @language_command_default_binary = val if val != Poise::NOT_PASSED
  @language_command_default_binary
end

#language_command_mixin(name, runtime: :"#{name}_runtime", timeout: true, default_binary: nil)

This method returns an undefined value.

Configure this module or class for a specific language.

Parameters:

  • name (Symbol)

    Language name.

  • runtime (Symbol) (defaults to: :"#{name}_runtime")

    Language runtime resource name.

  • timeout (Boolean) (defaults to: true)

    Enable the timeout attribute.

  • default_binary (String) (defaults to: nil)

    Name of the default language binary.

Since:

  • 1.0.0



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/poise_languages/command/mixin.rb', line 127

def language_command_mixin(name, runtime: :"#{name}_runtime", timeout: true, default_binary: nil)
  # Create the parent attribute.
  parent_attribute(name, type: runtime, optional: true)

  # Timeout attribute for the shell_out wrappers in the provider.
  attribute(:timeout, kind_of: Integer, default: 900) if timeout

  # Create the main accessor for the parent/path.
  define_method(name) do |val=Poise::NOT_PASSED|
    language_command_runtime(name, runtime, default_binary, val)
  end

  # Create the method to inherit settings from another resource.
  define_method(:"#{name}_from_parent") do |resource|
    language_command_runtime_from_parent(name, resource)
  end
  private :"#{name}_from_parent"
end