Class: Fix::Builder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/fix/builder.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Handles the creation and setup of Fix specifications.

The Builder constructs new Fix specification sets following these steps:

  1. Creates a new specification class inheriting from DSL

  2. Defines the specification content using the provided block

  3. Optionally registers the named specification

  4. Returns the built specification set

Examples:

Create a named specification

Fix::Builder.build(:Calculator) do
  on(:add, 2, 3) { it MUST equal 5 }
end

Create an anonymous specification

Fix::Builder.build do
  it MUST be_positive
end

See Also:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, &block) ⇒ Builder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Builder.



46
47
48
49
50
51
# File 'lib/fix/builder.rb', line 46

def initialize(name = nil, &block)
  raise Error::MissingSpecificationBlock unless block

  @name = name
  @block = block
end

Instance Attribute Details

#nameString, ... (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The name of the specification.

Returns:

  • (String, Symbol, nil)

    The name of the specification



44
45
46
# File 'lib/fix/builder.rb', line 44

def name
  @name
end

Class Method Details

.build(name = nil) {|Block| ... } ⇒ Fix::Set

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates a new specification set.

Parameters:

  • name (String, Symbol, nil) (defaults to: nil)

    Optional name for the specification

Yield Parameters:

  • Block (void)

    containing specification definitions

Yield Returns:

  • (void)

Returns:

  • (Fix::Set)

    The constructed specification set

Raises:



39
40
41
# File 'lib/fix/builder.rb', line 39

def self.build(name = nil, &block)
  new(name, &block).construct_set
end

Instance Method Details

#construct_setFix::Set

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Constructs and returns a new specification set.

Returns:

  • (Fix::Set)

    The constructed specification set



56
57
58
59
60
61
# File 'lib/fix/builder.rb', line 56

def construct_set
  klass = create_specification
  populate_specification(klass)
  register_if_named(klass)
  build_set(klass)
end