class Eapi::DefinitionRunners::Property

Public Instance Methods

run() click to toggle source
# File lib/eapi/definition_runners/property.rb, line 5
def run
  run_multiple_accessor
  run_multiple_clearer
  run_init
  run_validations
  run_allow_raw
end

Private Instance Methods

allow_raw?() click to toggle source
# File lib/eapi/definition_runners/property.rb, line 97
def allow_raw?
  definition.fetch(:allow_raw, false)
end
element_type() click to toggle source
# File lib/eapi/definition_runners/property.rb, line 105
def element_type
  definition.fetch(:element_type, nil)
end
init_class() click to toggle source
# File lib/eapi/definition_runners/property.rb, line 113
def init_class
  definition.fetch(:init_class, nil)
end
multiple?() click to toggle source
# File lib/eapi/definition_runners/property.rb, line 89
def multiple?
  definition.fetch(:multiple, false) || type_multiple?(type) || type_multiple?(init_class)
end
required?() click to toggle source
# File lib/eapi/definition_runners/property.rb, line 93
def required?
  definition.fetch(:required, false)
end
run_allow_raw() click to toggle source
# File lib/eapi/definition_runners/property.rb, line 52
def run_allow_raw
  Runner.allow_raw(klass: klass, field: field, allow_raw: allow_raw?)
end
run_init() click to toggle source
# File lib/eapi/definition_runners/property.rb, line 56
def run_init
  if init_class
    Runner.init(klass: klass, field: field, type: init_class)
  elsif multiple? && (type.blank? || type.to_s == 'Array')
    Runner.init(klass: klass, field: field, type: Array)
  end
end
run_multiple_accessor() click to toggle source
# File lib/eapi/definition_runners/property.rb, line 64
def run_multiple_accessor
  if multiple?
    Runner.multiple_accessor(klass: klass, field: field)
  end
end
run_multiple_clearer() click to toggle source
# File lib/eapi/definition_runners/property.rb, line 70
def run_multiple_clearer
  if multiple?
    Runner.multiple_clearer(klass: klass, field: field)
  end
end
run_required() click to toggle source
# File lib/eapi/definition_runners/property.rb, line 22
def run_required
  if required?
    Runner.required klass: klass, field: field
  end
end
run_validate_element_type() click to toggle source
# File lib/eapi/definition_runners/property.rb, line 34
def run_validate_element_type
  if multiple? && element_type
    Runner.validate_element_type(klass: klass, field: field, element_type: element_type)
  end
end
run_validate_element_with() click to toggle source
# File lib/eapi/definition_runners/property.rb, line 28
def run_validate_element_with
  if multiple? && validate_element_with
    Runner.validate_element_with klass: klass, field: field, validate_element_with: validate_element_with
  end
end
run_validate_type() click to toggle source
# File lib/eapi/definition_runners/property.rb, line 40
def run_validate_type
  if type
    Runner.validate_type(klass: klass, field: field, type: type)
  end
end
run_validate_with() click to toggle source
# File lib/eapi/definition_runners/property.rb, line 46
def run_validate_with
  if validate_with
    Runner.validate_with(klass: klass, field: field, validate_with: validate_with)
  end
end
run_validations() click to toggle source
# File lib/eapi/definition_runners/property.rb, line 14
def run_validations
  run_required
  run_validate_type
  run_validate_with
  run_validate_element_type
  run_validate_element_with
end
type() click to toggle source
# File lib/eapi/definition_runners/property.rb, line 109
def type
  definition.fetch(:type, nil)
end
type_multiple?(type) click to toggle source
# File lib/eapi/definition_runners/property.rb, line 76
def type_multiple?(type)
  type_class = Eapi::TypeChecker.constant_for_type type

  return false if type_class.nil?
  return true if type_class == Array || type_class == Set

  type_class.respond_to?(:is_multiple?) && type_class.is_multiple?
end
validate_element_with() click to toggle source
# File lib/eapi/definition_runners/property.rb, line 85
def validate_element_with
  definition.fetch(:validate_element_with, nil)
end
validate_with() click to toggle source
# File lib/eapi/definition_runners/property.rb, line 101
def validate_with
  definition.fetch(:validate_with, nil)
end