Class: Limit
- Inherits:
-
Object
- Object
- Limit
- Defined in:
- lib/better_rate_limit/limit.rb
Instance Attribute Summary collapse
-
#controller_path ⇒ Object
readonly
Returns the value of attribute controller_path.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
Class Method Summary collapse
Instance Method Summary collapse
- #_if ⇒ Object
- #_unless ⇒ Object
- #clear_if ⇒ Object
- #clear_if_present? ⇒ Boolean
- #controller_path_is?(controller_path) ⇒ Boolean
- #every ⇒ Object
- #except ⇒ Object
- #has_if_condition? ⇒ Boolean
- #has_unless_condition? ⇒ Boolean
-
#initialize(max, controller_path, options) ⇒ Limit
constructor
A new instance of Limit.
- #key(key_scope) ⇒ Object
- #name ⇒ Object
- #only ⇒ Object
- #scope ⇒ Object
Constructor Details
#initialize(max, controller_path, options) ⇒ Limit
Returns a new instance of Limit.
18 19 20 21 22 |
# File 'lib/better_rate_limit/limit.rb', line 18 def initialize(max, controller_path, ) @max = max @controller_path = controller_path @options = end |
Instance Attribute Details
#controller_path ⇒ Object (readonly)
Returns the value of attribute controller_path.
16 17 18 |
# File 'lib/better_rate_limit/limit.rb', line 16 def controller_path @controller_path end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
16 17 18 |
# File 'lib/better_rate_limit/limit.rb', line 16 def max @max end |
Class Method Details
.build(max, controller_path, options) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/better_rate_limit/limit.rb', line 2 def self.build(max, controller_path, ) .assert_valid_keys(:if, :unless, :every, :name, :scope, :only, :except, :clear_if) new(max, controller_path, { if: [:if], unless: [:unless], every: [:every], name: [:name], scope: [:scope], only: [:only], except: [:except], clear_if: [:clear_if] }) end |
Instance Method Details
#_if ⇒ Object
24 25 26 |
# File 'lib/better_rate_limit/limit.rb', line 24 def _if @options[:if] end |
#_unless ⇒ Object
36 37 38 |
# File 'lib/better_rate_limit/limit.rb', line 36 def _unless @options[:unless] end |
#clear_if ⇒ Object
52 53 54 |
# File 'lib/better_rate_limit/limit.rb', line 52 def clear_if @options[:clear_if] end |
#clear_if_present? ⇒ Boolean
56 57 58 |
# File 'lib/better_rate_limit/limit.rb', line 56 def clear_if_present? @options[:clear_if].present? end |
#controller_path_is?(controller_path) ⇒ Boolean
68 69 70 |
# File 'lib/better_rate_limit/limit.rb', line 68 def controller_path_is?(controller_path) self.controller_path == controller_path end |
#every ⇒ Object
32 33 34 |
# File 'lib/better_rate_limit/limit.rb', line 32 def every @options[:every] end |
#except ⇒ Object
40 41 42 |
# File 'lib/better_rate_limit/limit.rb', line 40 def except @options[:except] end |
#has_if_condition? ⇒ Boolean
60 61 62 |
# File 'lib/better_rate_limit/limit.rb', line 60 def has_if_condition? _if.present? end |
#has_unless_condition? ⇒ Boolean
64 65 66 |
# File 'lib/better_rate_limit/limit.rb', line 64 def has_unless_condition? _unless.present? end |
#key(key_scope) ⇒ Object
72 73 74 |
# File 'lib/better_rate_limit/limit.rb', line 72 def key(key_scope) ['controller_throttle', name, max, every, key_scope].join(':') end |
#name ⇒ Object
28 29 30 |
# File 'lib/better_rate_limit/limit.rb', line 28 def name @options[:name] end |
#only ⇒ Object
44 45 46 |
# File 'lib/better_rate_limit/limit.rb', line 44 def only @options[:only] end |
#scope ⇒ Object
48 49 50 |
# File 'lib/better_rate_limit/limit.rb', line 48 def scope @options[:scope] end |