class Surikat::BaseModel

Public Class Methods

create_random() click to toggle source

Used when running tests

# File lib/surikat/base_model.rb, line 13
def self.create_random
  create random_params
end
random_params() click to toggle source
# File lib/surikat/base_model.rb, line 17
def self.random_params
  params = {}
  columns.each do |col|
    next if ['id', 'created_at', 'updated_at'].include?(col.name)
    params[col.name] = case col.type.to_s
                       when 'string'
                         "Some String #{SecureRandom.hex(4)}"
                       when 'float', 'integer'
                         rand(100)
                       when 'boolean'
                         [true, false].sample
                       end
  end
  params
end