Class: ActiveCanvas::Partial

Inherits:
ApplicationRecord show all
Defined in:
app/models/active_canvas/partial.rb

Constant Summary collapse

TYPES =
%w[header footer].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



25
26
27
# File 'app/models/active_canvas/partial.rb', line 25

def active_footer
  active.find_by(partial_type: "footer")
end

.active_headerObject



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


17
18
19
# File 'app/models/active_canvas/partial.rb', line 17

def footer
  find_by(partial_type: "footer")
end

.headerObject



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

Returns:

  • (Boolean)


44
45
46
# File 'app/models/active_canvas/partial.rb', line 44

def footer?
  partial_type == "footer"
end

#full_cssObject



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

Returns:

  • (Boolean)


40
41
42
# File 'app/models/active_canvas/partial.rb', line 40

def header?
  partial_type == "header"
end

#rendered_contentObject



48
49
50
# File 'app/models/active_canvas/partial.rb', line 48

def rendered_content
  content.to_s.html_safe
end