Class: Pageflow::Account

Inherits:
ApplicationRecord show all
Includes:
FeatureTarget, SerializationBlacklist
Defined in:
app/models/pageflow/account.rb

Constant Summary

Constants included from FeatureTarget

FeatureTarget::STATE_MAPPING

Instance Method Summary collapse

Methods included from SerializationBlacklist

#serializable_hash

Methods included from FeatureTarget

#enabled_feature_names, #feature_state, #feature_states=, #features_configuration, #inherited_feature_state, #own_feature_state

Instance Method Details

#blacklist_for_serializationObject



53
54
55
# File 'app/models/pageflow/account.rb', line 53

def blacklist_for_serialization
  [:features_configuration]
end

#build_default_theming(*args) ⇒ Object



23
24
25
26
27
# File 'app/models/pageflow/account.rb', line 23

def build_default_theming(*args)
  super.tap do |theming|
    theming. = self
  end
end

#existing_and_potential_entry_templatesObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/models/pageflow/account.rb', line 33

def existing_and_potential_entry_templates
  entry_type_names = Pageflow.config_for(self).entry_types.map(&:name)
  existing_entry_templates = EntryTemplate.where(account_id: id).load
  allowed_existing_entry_templates =
    existing_entry_templates.select do |template|
      entry_type_names.include?(template.entry_type_name)
    end
  free_type_names =
    entry_type_names - allowed_existing_entry_templates.map(&:entry_type_name)

  potential_entry_templates = free_type_names.map do |type_name|
    EntryTemplate.new(
      account_id: id,
      entry_type_name: type_name
    )
  end

  allowed_existing_entry_templates + potential_entry_templates
end

#first_paged_entry_templateObject



29
30
31
# File 'app/models/pageflow/account.rb', line 29

def first_paged_entry_template
  EntryTemplate.find_or_initialize_by(account: self, entry_type_name: 'paged')
end