Module: Constraintable
- Defined in:
- lib/active_endpoint/concerns/constraintable.rb
Instance Method Summary collapse
- #constraints(options) ⇒ Object
- #default_constraints ⇒ Object
- #default_rule_constraints ⇒ Object
- #default_storage_constraints ⇒ Object
- #rule_constraints(options) ⇒ Object
- #storage_constraints(options) ⇒ Object
Instance Method Details
#constraints(options) ⇒ Object
2 3 4 5 6 7 |
# File 'lib/active_endpoint/concerns/constraintable.rb', line 2 def constraints() { rule: rule_constraints(), storage: storage_constraints() } end |
#default_constraints ⇒ Object
31 32 33 34 35 36 |
# File 'lib/active_endpoint/concerns/constraintable.rb', line 31 def default_constraints { rule: default_rule_constraints, storage: default_storage_constraints } end |
#default_rule_constraints ⇒ Object
38 39 40 41 42 43 |
# 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 ⇒ Object
45 46 47 48 49 50 |
# 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) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/active_endpoint/concerns/constraintable.rb', line 9 def rule_constraints() = fetch_rule() defined_rule_constraints = { limit: fetch_limit(), period: fetch_period() }.reject { |_key, value| value.nil? } default_rule_constraints.merge(defined_rule_constraints) end |
#storage_constraints(options) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/active_endpoint/concerns/constraintable.rb', line 20 def storage_constraints() = fetch_storage() defined_storage_constraints = { limit: fetch_limit(), period: fetch_period() }.reject { |_key, value| value.nil? } default_storage_constraints.merge(defined_storage_constraints) end |