Class: Pulitzer::Partial
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Pulitzer::Partial
- Defined in:
- app/models/pulitzer/partial.rb
Instance Method Summary collapse
- #available_arrangements ⇒ Object
- #available_backgrounds ⇒ Object
- #available_justifications ⇒ Object
- #available_sequence_flows ⇒ Object
- #background_css_class ⇒ Object
- #clone_me ⇒ Object
- #content_element(label) ⇒ Object
- #folder_path ⇒ Object
- #full_view_path ⇒ Object
- #handle_sort_order ⇒ Object
- #justification_css_class ⇒ Object
- #sequence_flow_css_class ⇒ Object
- #template_path ⇒ Object
- #version_folder ⇒ Object
Instance Method Details
#available_arrangements ⇒ Object
52 53 54 |
# File 'app/models/pulitzer/partial.rb', line 52 def available_arrangements post_type_version.arrangement_styles end |
#available_backgrounds ⇒ Object
40 41 42 |
# File 'app/models/pulitzer/partial.rb', line 40 def available_backgrounds post_type_version.background_styles end |
#available_justifications ⇒ Object
44 45 46 |
# File 'app/models/pulitzer/partial.rb', line 44 def available_justifications post_type_version.justification_styles end |
#available_sequence_flows ⇒ Object
48 49 50 |
# File 'app/models/pulitzer/partial.rb', line 48 def available_sequence_flows post_type_version.sequence_flow_styles end |
#background_css_class ⇒ Object
22 23 24 |
# File 'app/models/pulitzer/partial.rb', line 22 def background_css_class background_style&.css_class_name end |
#clone_me ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/models/pulitzer/partial.rb', line 76 def clone_me clone_attrs = self.attributes.dup clone_attrs.delete 'id' clone_attrs.delete 'free_form_section_id' my_clone = Pulitzer::Partial.create!(clone_attrs) content_elements.each do |ce| cloned_content_element = ce.clone_me my_clone.content_elements << cloned_content_element end my_clone end |
#content_element(label) ⇒ Object
18 19 20 |
# File 'app/models/pulitzer/partial.rb', line 18 def content_element(label) self.content_elements.find_by(label: label) end |
#folder_path ⇒ Object
56 57 58 |
# File 'app/models/pulitzer/partial.rb', line 56 def folder_path name.downcase.gsub(/ /,'_').gsub(/\W/,'') end |
#full_view_path ⇒ Object
72 73 74 |
# File 'app/models/pulitzer/partial.rb', line 72 def full_view_path File.join Pulitzer.partial_folder, folder_path, version_folder, template_path end |
#handle_sort_order ⇒ Object
34 35 36 37 38 |
# File 'app/models/pulitzer/partial.rb', line 34 def handle_sort_order if new_record? && sort_order.nil? self.sort_order = free_form_section.partials.maximum(:sort_order).to_i + 1 end end |
#justification_css_class ⇒ Object
26 27 28 |
# File 'app/models/pulitzer/partial.rb', line 26 def justification_css_class justification_style&.css_class_name end |
#sequence_flow_css_class ⇒ Object
30 31 32 |
# File 'app/models/pulitzer/partial.rb', line 30 def sequence_flow_css_class sequence_flow_style&.css_class_name end |
#template_path ⇒ Object
64 65 66 67 68 69 70 |
# File 'app/models/pulitzer/partial.rb', line 64 def template_path if arrangement_style.present? arrangement_style.view_file_name else 'default' end end |
#version_folder ⇒ Object
60 61 62 |
# File 'app/models/pulitzer/partial.rb', line 60 def version_folder "v_#{version_number}" end |