Skip to Content Skip to Search
Methods
B
C
F
I

Class Public methods

build_default(options = {})

# File app/models/db/theme.rb, line 10
def build_default(options = {})
  new(defaults.deep_merge(options))
end

ignored_attributes()

# File app/models/db/theme.rb, line 6
def ignored_attributes
  %w[id site_id]
end

Instance Public methods

custom_styles()

We only store those elements that are different from the default style, so to distinguish items that have been custom styled we simply have to remove the null columns

# File app/models/db/theme.rb, line 52
def custom_styles
  attributes.compact.without(self.class.ignored_attributes)
end

custom_styles_by_element()

Alias for: custom_styling

custom_styling()

Also aliased as: custom_styles_by_element
# File app/models/db/theme.rb, line 34
def custom_styling
  result = {}

  custom_styles.each do |key, value|
    element, property = key.split("__")

    result[element] ||= {}
    result[element][property] = value
  end

  result.with_indifferent_access
end

custom_styling=(style)

# File app/models/db/theme.rb, line 23
def custom_styling=(style)
  reset_styles

  style.each do |element, properties|
    properties.each do |property_name, value|
      attribute = [element, property_name].join("__").underscore
      send("#{attribute}=", value)
    end
  end
end

fonts()

# File app/models/db/theme.rb, line 56
def fonts
  @_fonts ||= attributes
    .slice(*self.class.column_names.grep(/font_family\z/i))
    .values
    .uniq
    .compact
    .map(&:titleize)
end