Module: EffectivePosts

Includes:
EffectiveGem
Defined in:
lib/effective_posts.rb,
lib/effective_posts/engine.rb,
lib/effective_posts/version.rb,
lib/generators/effective_posts/install_generator.rb

Defined Under Namespace

Modules: Generators Classes: Engine

Constant Summary collapse

VERSION =
'2.4.1'.freeze

Class Method Summary collapse

Class Method Details

.categoriesObject



46
47
48
# File 'lib/effective_posts.rb', line 46

def self.categories
  Array(config[:categories])
end

.category(value, safe: true) ⇒ Object

Normalize and return the category that matches this value



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/effective_posts.rb', line 34

def self.category(value, safe: true)
  values = [value, value.to_s, value.to_s.downcase, value.to_s.downcase.parameterize, value.to_s.parameterize]

  category = categories.find do |cat|
    (values & [cat, cat.to_s, cat.to_s.downcase, cat.to_s.downcase.parameterize, cat.to_s.parameterize]).present?
  end

  raise("Unable to find EffectivePosts.category for value '#{value.presence || 'nil'}'") unless safe

  category
end

.config_keysObject



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/effective_posts.rb', line 7

def self.config_keys
  [
    :posts_table_name, :layout, 
    :categories, :event_categories,
    :mailer, :parent_mailer, :deliver_method, :mailer_layout, :mailer_sender, :mailer_admin, :mailer_subject,
    :use_category_routes, :use_blog_routes,
    :use_effective_roles, :use_active_storage,
    :per_page, :post_meta_author,
    :submissions_enabled, :submissions_require_current_user,
    :submissions_require_approval, :submissions_note
  ]
end

.event_categoriesObject



50
51
52
# File 'lib/effective_posts.rb', line 50

def self.event_categories
  Array(config[:event_categories])
end

.mailer_classObject



22
23
24
# File 'lib/effective_posts.rb', line 22

def self.mailer_class
  mailer&.constantize || Effective::PostsMailer
end

.news_categoriesObject



58
59
60
# File 'lib/effective_posts.rb', line 58

def self.news_categories
  categories - event_categories
end

.not_event_categoriesObject



54
55
56
# File 'lib/effective_posts.rb', line 54

def self.not_event_categories
  categories - event_categories
end

.permitted_paramsObject



26
27
28
29
30
31
# File 'lib/effective_posts.rb', line 26

def self.permitted_params
  @permitted_params ||= [
    :title, :excerpt, :description, :draft, :category, :slug, :published_at, :body, :tags, :extra,
    :image, :start_at, :end_at, :location, :website_name, :website_href, roles: []
  ]
end