Class: Interdependence::Model::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/interdependence/model/validator.rb

Overview

Validator wrapper for validators added to model classes

Instance Method Summary collapse

Instance Method Details

#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.

Dependencies from resolver

Returns:



76
# File 'lib/interdependence/model/validator.rb', line 76

delegate :dependencies, to: :resolver

#fieldundefined

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 validator

Returns:

  • (undefined)


22
# File 'lib/interdependence/model/validator.rb', line 22

attribute :field, Symbol

#modelClass

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.

Model that owns this validator

Returns:

  • (Class)

    class that implements ActiveModel::Model



14
# File 'lib/interdependence/model/validator.rb', line 14

attribute :model, Class

#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.

Validator options hash

Returns:

  • (Hash)

    options passed to validator



38
# File 'lib/interdependence/model/validator.rb', line 38

attribute :options, Hash, default: {}

#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 validator options hash

Parameters:

  • options (Hash)

    options passed to validator

Returns:

  • (undefined)


64
65
66
67
# File 'lib/interdependence/model/validator.rb', line 64

def options=(options)
  self.substitutions = options.fetch(:dependencies, {})
  super
end

#resolverDependencyResolver::Model

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.

Memoized resolver

Returns:



94
95
96
# File 'lib/interdependence/model/validator.rb', line 94

def resolver
  @resolver ||= DependencyResolver::Model.new(self)
end

#saveundefined

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.

Merge model dependencies with resolver dependencies

Returns:

  • (undefined)


84
85
86
# File 'lib/interdependence/model/validator.rb', line 84

def save
  model.dependencies.merge!(dependencies)
end

#substitutionsHash{Symbol => Symbol}

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.

Map for substituting names on validator

Returns:

  • (Hash{Symbol => Symbol})
    substitution map


46
# File 'lib/interdependence/model/validator.rb', line 46

attribute :substitutions, Hash[Symbol => Symbol], default: {}

#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

Returns:

  • (Class)
    descendant of ActiveModel::Validator


30
# File 'lib/interdependence/model/validator.rb', line 30

attribute :validator_class, Class