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
Instance Method Details
#available_arrangements ⇒ Object
50 51 52 |
# File 'app/models/pulitzer/partial.rb', line 50 def available_arrangements post_type.arrangement_styles end |
#available_backgrounds ⇒ Object
38 39 40 |
# File 'app/models/pulitzer/partial.rb', line 38 def available_backgrounds post_type.background_styles end |
#available_justifications ⇒ Object
42 43 44 |
# File 'app/models/pulitzer/partial.rb', line 42 def available_justifications post_type.justification_styles end |
#available_sequence_flows ⇒ Object
46 47 48 |
# File 'app/models/pulitzer/partial.rb', line 46 def available_sequence_flows post_type.sequence_flow_styles end |
#background_css_class ⇒ Object
20 21 22 |
# File 'app/models/pulitzer/partial.rb', line 20 def background_css_class background_style&.css_class_name end |
#clone_me ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/models/pulitzer/partial.rb', line 70 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
16 17 18 |
# File 'app/models/pulitzer/partial.rb', line 16 def content_element(label) self.content_elements.find_by(label: label) end |
#folder_path ⇒ Object
54 55 56 |
# File 'app/models/pulitzer/partial.rb', line 54 def folder_path name.downcase.gsub(/ /,'_').gsub(/\W/,'') end |
#full_view_path ⇒ Object
66 67 68 |
# File 'app/models/pulitzer/partial.rb', line 66 def full_view_path Pulitzer.partial_folder + '/' + folder_path + '/' + template_path end |
#handle_sort_order ⇒ Object
32 33 34 35 36 |
# File 'app/models/pulitzer/partial.rb', line 32 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
24 25 26 |
# File 'app/models/pulitzer/partial.rb', line 24 def justification_css_class justification_style&.css_class_name end |
#sequence_flow_css_class ⇒ Object
28 29 30 |
# File 'app/models/pulitzer/partial.rb', line 28 def sequence_flow_css_class sequence_flow_style&.css_class_name end |
#template_path ⇒ Object
58 59 60 61 62 63 64 |
# File 'app/models/pulitzer/partial.rb', line 58 def template_path if arrangement_style.present? arrangement_style.view_file_name else 'default' end end |