Class: ActiveCanvas::Partial
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ActiveCanvas::Partial
- Defined in:
- app/models/active_canvas/partial.rb
Constant Summary collapse
- TYPES =
%w[header footer].freeze
Class Method Summary collapse
- .active_footer ⇒ Object
- .active_header ⇒ Object
-
.ensure_defaults! ⇒ Object
Ensure both partials exist.
- .footer ⇒ Object
- .header ⇒ Object
Instance Method Summary collapse
Class Method Details
.active_footer ⇒ Object
25 26 27 |
# File 'app/models/active_canvas/partial.rb', line 25 def active.find_by(partial_type: "footer") end |
.active_header ⇒ Object
21 22 23 |
# File 'app/models/active_canvas/partial.rb', line 21 def active_header active.find_by(partial_type: "header") end |
.ensure_defaults! ⇒ Object
Ensure both partials exist
30 31 32 33 34 35 36 37 |
# File 'app/models/active_canvas/partial.rb', line 30 def ensure_defaults! find_or_create_by!(partial_type: "header") do |p| p.name = "Header" end find_or_create_by!(partial_type: "footer") do |p| p.name = "Footer" end end |
.footer ⇒ Object
17 18 19 |
# File 'app/models/active_canvas/partial.rb', line 17 def find_by(partial_type: "footer") end |
.header ⇒ Object
13 14 15 |
# File 'app/models/active_canvas/partial.rb', line 13 def header find_by(partial_type: "header") end |
Instance Method Details
#footer? ⇒ Boolean
44 45 46 |
# File 'app/models/active_canvas/partial.rb', line 44 def partial_type == "footer" end |
#full_css ⇒ Object
52 53 54 |
# File 'app/models/active_canvas/partial.rb', line 52 def full_css [compiled_css, content_css].compact.join("\n") end |
#header? ⇒ Boolean
40 41 42 |
# File 'app/models/active_canvas/partial.rb', line 40 def header? partial_type == "header" end |
#rendered_content ⇒ Object
48 49 50 |
# File 'app/models/active_canvas/partial.rb', line 48 def rendered_content content.to_s.html_safe end |