Class: Configurations::StrictConfiguration

Inherits:
Configuration show all
Defined in:
lib/configurations/strict.rb

Overview

StrictConfiguration is a blank object with setters and getters defined according to the configurable settings given

Constant Summary

Constants inherited from BlankObject

BlankObject::ALIAS_KERNEL_METHODS, BlankObject::KEEP_KERNEL_METHODS, BlankObject::KEEP_METHODS

Instance Method Summary collapse

Methods inherited from Configuration

#__configured?, #__empty?, #from_h, #method_missing, #respond_to_missing?, #to_h

Methods inherited from BlankObject

blank_kernel

Constructor Details

#initialize(options = {}, &block) {|HostModule::Configuration| ... } ⇒ HostModule::Configuration

Initialize a new configuration

Parameters:

  • options (Hash) (defaults to: {})

    The options to initialize a configuration with

  • block (Proc)

    a block to configure this configuration with

Options Hash (options):

  • configurable (Hash)

    a hash of configurable properties and their asserted types if given

  • methods (Hash)

    a hash of method names pointing to procs

  • not_configured (Proc)

    a proc to evaluate for not_configured properties

Yields:

  • (HostModule::Configuration)

    a configuration



18
19
20
21
22
23
# File 'lib/configurations/strict.rb', line 18

def initialize(options = {}, &block)
  @__configurable__   = options.fetch(:configurable)
  __evaluate_configurable!

  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Configurations::Configuration

Instance Method Details

#__configurable?(property) ⇒ Boolean

Returns whether the given property is configurable.

Parameters:

  • property (Symbol)

    The property to test for configurability

Returns:

  • (Boolean)

    whether the given property is configurable



28
29
30
31
# File 'lib/configurations/strict.rb', line 28

def __configurable?(property)
  @__configurable__.key?(property) ||
    @__nested_configurables__.key?(property)
end