Class: DirtySeed::Assigners::Meaningful

Inherits:
Assigner
  • Object
show all
Includes:
FakerHelper
Defined in:
lib/dirty_seed/assigners/meaningful.rb

Overview

Manages attributes that are meaningful

Instance Method Summary collapse

Methods included from FakerHelper

#faker_value

Instance Method Details

#respond?Boolean

Note:

For instance, if there is a faker match but faker return a string And the attribute type is float then return false

Can meaning be guessed and does faker type match attribute type?

Returns:

  • (Boolean)


21
22
23
# File 'lib/dirty_seed/assigners/meaningful.rb', line 21

def respond?
  @respond ||= meaningful_options.present? && meaningful_options[:types].include?(type.to_s)
end

#valueObject

Returns a random meaningful value

Returns:

  • (Object)

    a “primitive”



11
12
13
14
15
# File 'lib/dirty_seed/assigners/meaningful.rb', line 11

def value
  return unless respond?

  faker_value(meaningful_options.except(:types))
end