Class: Boothby::Plant

Inherits:
Object
  • Object
show all
Defined in:
lib/boothby/seeds.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.config_file=(value) ⇒ Object

Sets the attribute config_file

Parameters:

  • value

    the value to set the attribute config_file to.



8
9
10
# File 'lib/boothby/seeds.rb', line 8

def config_file=(value)
  @config_file = value
end

.rails_env=(value) ⇒ Object

Sets the attribute rails_env

Parameters:

  • value

    the value to set the attribute rails_env to.



8
9
10
# File 'lib/boothby/seeds.rb', line 8

def rails_env=(value)
  @rails_env = value
end

.root=(value) ⇒ Object

Sets the attribute root

Parameters:

  • value

    the value to set the attribute root to.



8
9
10
# File 'lib/boothby/seeds.rb', line 8

def root=(value)
  @root = value
end

Class Method Details

.seed!Object



11
12
13
14
15
16
# File 'lib/boothby/seeds.rb', line 11

def self.seed!
  require_seed_modules!

  seed(environment: :base)
  seed(environment: rails_env)
end

.seed_from(seed_class) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/boothby/seeds.rb', line 70

def self.seed_from(seed_class)
  multi_spinner.register(
    '[:spinner] :title',
    hide_cursor: true,
    success_mark: pastel.green(''),
    error_mark: pastel.red('×'),
    interval: 5,
    format: :arc
  ) do |spinner|
    title = seed_method[4..-1].titleize
    spinner.update(title: "Seeding #{title}")
    seed_class.public_send(seed_method)
    spinner.update(title: "Seeded #{title}")
    spinner.success
  end
end

.seed_methods(seed_class) ⇒ Object



87
88
89
90
91
92
# File 'lib/boothby/seeds.rb', line 87

def self.seed_methods(seed_class)
  methods = seed_class.methods.map(&:to_s).select do |method|
    method.starts_with?('seed_')
  end
  methods.sort_by { |method| seed_class.method(method).source_location.last }
end