Class: ComfortableMexicanSofa::Seeds::Importer
- Inherits:
-
Object
- Object
- ComfortableMexicanSofa::Seeds::Importer
- Defined in:
- lib/comfortable_mexican_sofa/seeds.rb
Direct Known Subclasses
File::Importer, Layout::Importer, Page::Importer, Snippet::Importer
Instance Attribute Summary collapse
-
#from ⇒ Object
Returns the value of attribute from.
-
#path ⇒ Object
Returns the value of attribute path.
-
#seed_ids ⇒ Object
Returns the value of attribute seed_ids.
-
#site ⇒ Object
Returns the value of attribute site.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
-
#import!(classes = nil) ⇒ Object
if passed nil will use default seed classes.
-
#initialize(from, to = from) ⇒ Importer
constructor
‘from` and `to` indicate site identifier and folder name.
Constructor Details
#initialize(from, to = from) ⇒ Importer
‘from` and `to` indicate site identifier and folder name
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/comfortable_mexican_sofa/seeds.rb', line 20 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
#from ⇒ Object
Returns the value of attribute from.
13 14 15 |
# File 'lib/comfortable_mexican_sofa/seeds.rb', line 13 def from @from end |
#path ⇒ Object
Returns the value of attribute path.
13 14 15 |
# File 'lib/comfortable_mexican_sofa/seeds.rb', line 13 def path @path end |
#seed_ids ⇒ Object
Returns the value of attribute seed_ids.
13 14 15 |
# File 'lib/comfortable_mexican_sofa/seeds.rb', line 13 def seed_ids @seed_ids end |
#site ⇒ Object
Returns the value of attribute site.
13 14 15 |
# File 'lib/comfortable_mexican_sofa/seeds.rb', line 13 def site @site end |
#to ⇒ Object
Returns the value of attribute to.
13 14 15 |
# File 'lib/comfortable_mexican_sofa/seeds.rb', line 13 def to @to end |
Instance Method Details
#import!(classes = nil) ⇒ Object
if passed nil will use default seed classes
32 33 34 35 36 37 38 |
# File 'lib/comfortable_mexican_sofa/seeds.rb', line 32 def import!(classes = nil) classes ||= SEED_CLASSES classes.each do |klass| klass = "ComfortableMexicanSofa::Seeds::#{klass}::Importer" klass.constantize.new(from, to).import! end end |