Class: Sinclair::Model::Builder Private

Inherits:
Sinclair show all
Defined in:
lib/sinclair/model/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.

Builder responsible for building methods to a new Sinclair::Model class

The building adds readers/setters and an initializer with named parameters

Author:

  • Darthjee

Constant Summary

Constants inherited from Sinclair

VERSION

Instance Attribute Summary

Attributes inherited from Sinclair

#klass

Instance Method Summary collapse

Methods inherited from Sinclair

#add_class_method, #add_method, #build, build, #eval_and_add_method

Methods included from ClassMethods

#build

Methods included from OptionsParser

#options_object

Constructor Details

#initialize(klass, *attributes, writter: true, comparable: true) ⇒ Builder #initialize(klass, *attributes, defaults, writter: true, comparable: true) ⇒ 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.

Overloads:

  • #initialize(klass, *attributes, writter: true, comparable: true) ⇒ Builder

    Parameters:

    • klass (Class<Sinclair::Model>)

      the new class to receive the methods

    • attributes (Array<Symbol>)

      attributes to be added in both the initialization and adding the methos to the model

    • writter (TrueClass, FalseClass) (defaults to: true)

      flag informing if the writter/setter method should be added

    • comparable (TrueClass, FalseClass) (defaults to: true)

      flag to make the class Comparable by the fields

  • #initialize(klass, *attributes, defaults, writter: true, comparable: true) ⇒ Builder

    Parameters:

    • klass (Class<Sinclair::Model>)

      the new class to receive the methods

    • attributes (Array<Symbol>)

      attributes to be added in both the initialization and adding the methos to the model

    • defaults (Hash)

      attributes to be added with a default value in the initializer

    • writter (TrueClass, FalseClass) (defaults to: true)

      flag informing if the writter/setter method should be added

    • comparable (TrueClass, FalseClass) (defaults to: true)

      flag to make the class Comparable by the fields



29
30
31
32
33
34
35
36
37
# File 'lib/sinclair/model/builder.rb', line 29

def initialize(klass, *attributes, **options)
  super(klass)
  @attributes = attributes.flatten
  @options = BuilderOptions.new(**options)

  add_methods
  change_equals
  change_initializer
end