Class: ComfortableMexicanSofa::Seeds::Importer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, to = from) ⇒ Importer

‘from` and `to` indicate site identifier and folder name



18
19
20
21
22
23
24
25
26
27
# File 'lib/comfortable_mexican_sofa/seeds.rb', line 18

def initialize(from, to = from)
  self.from         = from
  self.to           = to
  self.site         = Comfy::Cms::Site.where(identifier: to).first!
  self.seed_ids     = []

  unless ::File.exist?(path = ::File.join(ComfortableMexicanSofa.config.seeds_path, from))
    raise Error, "Folder for import: '#{path}' is not found"
  end
end

Instance Attribute Details

#fromObject

Returns the value of attribute from.



11
12
13
# File 'lib/comfortable_mexican_sofa/seeds.rb', line 11

def from
  @from
end

#pathObject

Returns the value of attribute path.



11
12
13
# File 'lib/comfortable_mexican_sofa/seeds.rb', line 11

def path
  @path
end

#seed_idsObject

Returns the value of attribute seed_ids.



11
12
13
# File 'lib/comfortable_mexican_sofa/seeds.rb', line 11

def seed_ids
  @seed_ids
end

#siteObject

Returns the value of attribute site.



11
12
13
# File 'lib/comfortable_mexican_sofa/seeds.rb', line 11

def site
  @site
end

#toObject

Returns the value of attribute to.



11
12
13
# File 'lib/comfortable_mexican_sofa/seeds.rb', line 11

def to
  @to
end

Instance Method Details

#import!Object



29
30
31
32
33
34
# File 'lib/comfortable_mexican_sofa/seeds.rb', line 29

def import!
  %w[Layout Page Snippet File].each do |klass|
    klass = "ComfortableMexicanSofa::Seeds::#{klass}::Importer"
    klass.constantize.new(from, to).import!
  end
end