Class: Decidim::Pages::Seeds

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(participatory_space:) ⇒ Seeds

Returns a new instance of Seeds.



10
11
12
# File 'lib/decidim/pages/seeds.rb', line 10

def initialize(participatory_space:)
  @participatory_space = participatory_space
end

Instance Attribute Details

#participatory_spaceObject (readonly)

Returns the value of attribute participatory_space.



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

def participatory_space
  @participatory_space
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/decidim/pages/seeds.rb', line 14

def call
  component = Decidim::Component.create!(
    name: Decidim::Components::Namer.new(participatory_space.organization.available_locales, :pages).i18n_name,
    manifest_name: :pages,
    published_at: Time.current,
    participatory_space:
  )

  Decidim::Pages::Page.create!(
    component:,
    body: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
      Decidim::Faker::Localized.paragraph(sentence_count: 3)
    end
  )
end