Class: SmartCore::Initializer::AttributeDefiner Private

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_core/initializer/attribute_definer.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.

Since:

  • 0.5.0

Instance Method Summary collapse

Constructor Details

#initialize(processed_klass) ⇒ void

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.

Parameters:

  • processed_klass (Class)

Since:

  • 0.5.0



11
12
13
14
# File 'lib/smart_core/initializer/attribute_definer.rb', line 11

def initialize(processed_klass)
  @processed_klass = processed_klass
  @definition_lock = Mutex.new
end

Instance Method Details

#define_option(option_name, option_type = :__any__, **options) ⇒ void

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.

This method returns an undefined value.

Parameters:

  • option_name (Symbol, String)
  • option_type (String, Symbol) (defaults to: :__any__)

Since:

  • 0.5.0



53
54
55
56
57
58
59
60
# File 'lib/smart_core/initializer/attribute_definer.rb', line 53

def define_option(option_name, option_type = :__any__, **options)
  thread_safe do
    option = build_attribute(option_name, option_type, **options)
    prevent_intersection_with_already_defined_param(option)

    append_option(option)
  end
end

#define_options(*option_names) ⇒ void

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.

This method returns an undefined value.

Parameters:

  • option_names (Array<String, Symbol>)

Since:

  • 0.5.0



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/smart_core/initializer/attribute_definer.rb', line 67

def define_options(*option_names)
  thread_safe do
    options = option_names.map do |option_name|
      build_attribute(option_name).tap do |option|
        prevent_intersection_with_already_defined_param(option)
      end
    end

    options.each { |option| append_option(option) }
  end
end

#define_param(param_name, param_type = :__any__, **options) ⇒ void

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.

This method returns an undefined value.

Parameters:

  • param_name (Symbol, String)
  • param_type (String, Symbol) (defaults to: :__any__)

Since:

  • 0.5.0



22
23
24
25
26
27
28
# File 'lib/smart_core/initializer/attribute_definer.rb', line 22

def define_param(param_name, param_type = :__any__, **options)
  thread_safe do
    parameter = build_attribute(param_name, param_type, **options)
    prevent_intersection_with_already_defined_option(parameter)
    append_parameter(parameter)
  end
end

#define_params(*param_names) ⇒ void

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.

This method returns an undefined value.

Parameters:

  • param_names (Array<String, Symbol>)

Since:

  • 0.5.0



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/smart_core/initializer/attribute_definer.rb', line 35

def define_params(*param_names)
  thread_safe do
    parameters = param_names.map do |param_name|
      build_attribute(param_name).tap do |parameter|
        prevent_intersection_with_already_defined_option(parameter)
      end
    end

    parameters.each { |parameter| append_parameter(parameter) }
  end
end