module Constraintable

Public Instance Methods

constraints(options) click to toggle source
# File lib/active_endpoint/concerns/constraintable.rb, line 2
def constraints(options)
  {
    rule: rule_constraints(options),
    storage: storage_constraints(options)
  }
end
default_constraints() click to toggle source
# File lib/active_endpoint/concerns/constraintable.rb, line 31
def default_constraints
  {
    rule: default_rule_constraints,
    storage: default_storage_constraints
  }
end
default_rule_constraints() click to toggle source
# File lib/active_endpoint/concerns/constraintable.rb, line 38
def default_rule_constraints
  {
    limit: ActiveEndpoint.constraint_limit,
    period: ActiveEndpoint.constraint_period
  }
end
default_storage_constraints() click to toggle source
# File lib/active_endpoint/concerns/constraintable.rb, line 45
def default_storage_constraints
  {
    limit: ActiveEndpoint.storage_limit,
    period: ActiveEndpoint.storage_period
  }
end
rule_constraints(options) click to toggle source
# File lib/active_endpoint/concerns/constraintable.rb, line 9
def rule_constraints(options)
  rule_options = fetch_rule(options)

  defined_rule_constraints = {
    limit: fetch_limit(rule_options),
    period: fetch_period(rule_options)
  }.reject { |_key, value| value.nil? }

  default_rule_constraints.merge(defined_rule_constraints)
end
storage_constraints(options) click to toggle source
# File lib/active_endpoint/concerns/constraintable.rb, line 20
def storage_constraints(options)
  storage_options = fetch_storage(options)

  defined_storage_constraints = {
    limit: fetch_limit(storage_options),
    period: fetch_period(storage_options)
  }.reject { |_key, value| value.nil? }

  default_storage_constraints.merge(defined_storage_constraints)
end