Class: Pulitzer::GeneratorElementType
- Inherits:
-
Object
- Object
- Pulitzer::GeneratorElementType
- Defined in:
- lib/generators/pulitzer/post_type_generator.rb
Instance Method Summary collapse
- #content_element_injection_content ⇒ Object
- #free_form_section_injection_content ⇒ Object
-
#initialize(element_type) ⇒ GeneratorElementType
constructor
A new instance of GeneratorElementType.
- #injection_content ⇒ Object
Constructor Details
#initialize(element_type) ⇒ GeneratorElementType
Returns a new instance of GeneratorElementType.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/generators/pulitzer/post_type_generator.rb', line 5 def initialize(element_type) case element_type.class.name when "Pulitzer::PostTypeContentElementType" @label = element_type.label @kind = 'content_element' @optional = !element_type.required when 'Pulitzer::FreeFormSectionType' @label = element_type.name @kind = 'free_form_section' end end |
Instance Method Details
#content_element_injection_content ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/generators/pulitzer/post_type_generator.rb', line 22 def content_element_injection_content content = '' if @optional content += " <% if cms_content_present? @post.content_element('#{@label}') %>\n " end content += " <%= render_cms_element @post.content_element('#{@label}') %>\n" if @optional content += " <% end %>\n" end content end |
#free_form_section_injection_content ⇒ Object
34 35 36 37 38 39 |
# File 'lib/generators/pulitzer/post_type_generator.rb', line 34 def free_form_section_injection_content <<-VIEW <%= render_cms_section(@post, '#{@label}') %> VIEW end |
#injection_content ⇒ Object
17 18 19 20 |
# File 'lib/generators/pulitzer/post_type_generator.rb', line 17 def injection_content injection_content_method = "#{@kind}_injection_content" send injection_content_method end |