Sha256: aa37e1bb0ef7f07db742f30de809816df2133ee72e4b7d17956ec5f83e6773af

Contents?: true

Size: 1.16 KB

Versions: 16

Compression:

Stored size: 1.16 KB

Contents

# Stop-gap solution to allow us to keep mission-critical seed data somewhere
# accessible. Not too thrilled about it; refactor away.
module Landable
  module Seeds

    def self.seed key
      method_key = "seed_#{key}".to_sym
      if respond_to? method_key
        send method_key if ActiveRecord::Base.connection.schema_exists? "#{Landable.configuration.database_schema_prefix}landable"
      else
        raise NotImplementedError, "No seeds for key '#{key}'"
      end
    end

    private

    # Required data.
    def self.seed_required
      # categories ('Uncategorized' is mandatory)
      Landable::Category.where(name: 'Uncategorized').first_or_create!
      Landable.configuration.categories.each do |category_name, category_description|
        Landable::Category.where(name: category_name).first_or_create!(description: category_description)
      end
    end

    # Less required data.
    def self.seed_extras
      # themes
      Landable::Theme.where(name: 'Blank').first_or_create!(
        body: '',
        description: 'A completely blank theme; only the page body will be rendered.',
        thumbnail_url: 'http://placehold.it/300x200',
      )
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
landable-1.13.1 lib/landable/seeds.rb
landable-1.12.3 lib/landable/seeds.rb
landable-1.12.2 lib/landable/seeds.rb
landable-1.12.1 lib/landable/seeds.rb
landable-1.11.1 lib/landable/seeds.rb
landable-1.11.0 lib/landable/seeds.rb
landable-1.10.0.rc2 lib/landable/seeds.rb
landable-1.10.0.rc1 lib/landable/seeds.rb
landable-1.9.2 lib/landable/seeds.rb
landable-1.9.1 lib/landable/seeds.rb
landable-1.9.0 lib/landable/seeds.rb
landable-1.9.0.rc2 lib/landable/seeds.rb
landable-1.9.0.rc1 lib/landable/seeds.rb
landable-1.8.0 lib/landable/seeds.rb
landable-1.7.1.rc1 lib/landable/seeds.rb
landable-1.7.0 lib/landable/seeds.rb