Class: Decidim::DecidimAwesome::AwesomeConfig

Inherits:
ApplicationRecord show all
Defined in:
app/models/decidim/decidim_awesome/awesome_config.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for_organization(organization) ⇒ Object



27
28
29
# File 'app/models/decidim/decidim_awesome/awesome_config.rb', line 27

def self.for_organization(organization)
  where(organization:)
end

Instance Method Details

#add_constraints(constraints) ⇒ Object



21
22
23
24
25
# File 'app/models/decidim/decidim_awesome/awesome_config.rb', line 21

def add_constraints(constraints)
  return if constraints.blank?

  additional_constraints.concat(constraints.respond_to?(:each) ? constraints : [constraints])
end

#additional_constraintsObject



17
18
19
# File 'app/models/decidim/decidim_awesome/awesome_config.rb', line 17

def additional_constraints
  @additional_constraints ||= []
end

#all_constraintsObject

use this instead of “constraints” to evaluate dynamically added constants



32
33
34
# File 'app/models/decidim/decidim_awesome/awesome_config.rb', line 32

def all_constraints
  constraints + additional_constraints
end