Class: Adva::Static::Import::Model::Section
- Inherits:
-
Base
- Object
- Base
- Adva::Static::Import::Model::Section
show all
- Defined in:
- lib/adva/static/import/model/section.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#source
Instance Method Summary
collapse
Methods inherited from Base
#attribute?, #attribute_value, #attributes, #model, #model_name, #update!, #updated_record
Constructor Details
#initialize(source, site = nil, parent = nil) ⇒ Section
Returns a new instance of Section.
8
9
10
11
12
|
# File 'lib/adva/static/import/model/section.rb', line 8
def initialize(source, site = nil, parent = nil)
super(source)
@site = site
@parent = parent
end
|
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
6
7
8
|
# File 'lib/adva/static/import/model/section.rb', line 6
def parent
@parent
end
|
Instance Method Details
#attribute_names ⇒ Object
18
19
20
|
# File 'lib/adva/static/import/model/section.rb', line 18
def attribute_names
@attribute_names ||= super | [:site_id, :parent_id, :type, :name, :slug]
end
|
#parent_id ⇒ Object
38
39
40
|
# File 'lib/adva/static/import/model/section.rb', line 38
def parent_id
parent && parent.record.persisted? ? parent.record.id.to_s : nil
end
|
#record ⇒ Object
14
15
16
|
# File 'lib/adva/static/import/model/section.rb', line 14
def record
@record ||= model.find_or_initialize_by_slug(source.data.slug)
end
|
#site ⇒ Object
26
27
28
|
# File 'lib/adva/static/import/model/section.rb', line 26
def site
@site ||= Site.new(source.path.root)
end
|
#site_id ⇒ Object
30
31
32
|
# File 'lib/adva/static/import/model/section.rb', line 30
def site_id
site && site.record.persisted? ? site.record.id.to_s : nil
end
|
#type ⇒ Object
22
23
24
|
# File 'lib/adva/static/import/model/section.rb', line 22
def type
model_name
end
|