Class: Interdependence::Dependency::Base

Inherits:
Object
  • Object
show all
Includes:
Adamantium
Defined in:
lib/interdependence/dependency/base.rb

Overview

Base dependency wrapper class

Direct Known Subclasses

Model, Validator

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ true, false Also known as: eql?

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.

Is the other instance equivalent to this instance

Parameters:

  • other (instance of same class)

Returns:


136
137
138
139
140
141
# File 'lib/interdependence/dependency/base.rb', line 136

def ==(other)
  other.is_a?(Base) &&
    validator_class.equal?(other.validator_class) &&
    field.eql?(other.field) &&
    options.eql?(other.options)
end

#cloneDependency::Base

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.

Clone class

Returns:


73
74
75
# File 'lib/interdependence/dependency/base.rb', line 73

def clone
  self.class.new(self)
end

#dependenciesObservableDependencySetGraph

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.

Cloned copy of #validator_class's dependencies

Returns:


149
150
151
# File 'lib/interdependence/dependency/base.rb', line 149

def dependencies
  validator_class.dependencies.clone
end

#fieldField, UnsetField

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.

Field of dependency

Returns:

  • (Field)
    field wrapper
  • (UnsetField)
    unset field abstraction

26
# File 'lib/interdependence/dependency/base.rb', line 26

attribute :field, Types::Field, coercer: Types::FieldCoercer

#field=(field) ⇒ undefined

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.

Set field of dependency

Parameters:

Returns:

  • (undefined)

26
# File 'lib/interdependence/dependency/base.rb', line 26

attribute :field, Types::Field, coercer: Types::FieldCoercer

#field_nameSymbol

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.

Get name of field

Returns:

  • (Symbol)
    field name

164
# File 'lib/interdependence/dependency/base.rb', line 164

delegate :name, to: :field, prefix: true

#field_name=undefined

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.

Set name of field

Returns:

  • (undefined)

174
# File 'lib/interdependence/dependency/base.rb', line 174

delegate :name=, to: :field, prefix: true

#inspectString

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.

Make dependencies more readable

Returns:

  • (String)
    inspection string

83
84
85
86
87
# File 'lib/interdependence/dependency/base.rb', line 83

def inspect
  inspect_field = unspecified_field? ? '*' : field.name.inspect

  "\e[1;36m#<#{self.class} #{validator_class}(#{inspect_field}, #{options.inspect})>\e[0m"
end

#optionsHash

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.

Options for #validator_class (coerced with Types::OptionsCoercer). Memoized

Returns:

  • (Hash)
    options

63
# File 'lib/interdependence/dependency/base.rb', line 63

attribute :options, Hash, coercer: Types::OptionsCoercer

#options=(options) ⇒ undefined

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.

Set options

Parameters:

Returns:

  • (undefined)

63
# File 'lib/interdependence/dependency/base.rb', line 63

attribute :options, Hash, coercer: Types::OptionsCoercer

#unset_equivalent_of?(other) ⇒ true, false

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.

Is this instance the equivalent of `other` with unset attributes

Parameters:

  • other (instance of same class)

Returns:

  • (true)

    if field and options are unset and other has the same #validator_class

  • (true)

    if field is unset and other has the same options and #validator_class

  • (false)

    otherwise


121
122
123
124
125
# File 'lib/interdependence/dependency/base.rb', line 121

def unset_equivalent_of?(other)
  unspecified_field? &&
    (unspecified_options? || options.eql?(other.options)) &&
    validator_class.equal?(other.validator_class)
end

#unspecified_field?true, false

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.

is #field unset?

Returns:

  • (true)

    if field is a UnsetField

  • (false)

    otherwise


96
97
98
# File 'lib/interdependence/dependency/base.rb', line 96

def unspecified_field?
  field.instance_of?(Types::UnsetField)
end

#unspecified_options?true, false

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.

is #options unset?

Returns:

  • (true)

    if field is a UnsetOptions

  • (false)

    otherwise


107
108
109
# File 'lib/interdependence/dependency/base.rb', line 107

def unspecified_options?
  options.instance_of?(Types::UnsetOptions)
end

#validator_classClass

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.

Validator class of dependency (coerced with Types::ValidatorClassCoercer)

Returns:

  • (Class)
    descendant of ActiveModel::Validator

44
# File 'lib/interdependence/dependency/base.rb', line 44

attribute :validator_class, Class, coercer: Types::ValidatorClassCoercer, strict: true

#validator_class=(validator_class) ⇒ undefined

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.

Set validator class

Parameters:

  • validator_class (Class)

    descendant of ActiveModel::Validator

Returns:

  • (undefined)

44
# File 'lib/interdependence/dependency/base.rb', line 44

attribute :validator_class, Class, coercer: Types::ValidatorClassCoercer, strict: true