Class: Planify::Limitations
- Inherits:
-
Object
- Object
- Planify::Limitations
- Includes:
- ActiveSupport::Inflector, ClassHelper
- Defined in:
- lib/planify/limitations.rb
Overview
Planify::Limitations
is a simple container for Class constants and their associated limits
Instance Method Summary collapse
-
#all ⇒ Hash(String,Integer)
Returns all limits defined in this instance.
-
#get(klass, default_limit = Float::INFINITY) ⇒ Integer
Fetches the limit for the given class constant.
-
#initialize(limits = {}) ⇒ Limitations
constructor
A new instance of Limitations.
-
#set(klass, limit) ⇒ Integer
Sets the limit for the given class constant.
Methods included from ClassHelper
Constructor Details
#initialize(limits = {}) ⇒ Limitations
Returns a new instance of Limitations.
10 11 12 |
# File 'lib/planify/limitations.rb', line 10 def initialize(limits = {}) @limits = limits end |
Instance Method Details
#all ⇒ Hash(String,Integer)
Returns all limits defined in this instance
41 42 43 |
# File 'lib/planify/limitations.rb', line 41 def all @limits end |
#get(klass, default_limit = Float::INFINITY) ⇒ Integer
Fetches the limit for the given class constant
29 30 31 32 33 34 35 36 37 |
# File 'lib/planify/limitations.rb', line 29 def get(klass, default_limit = Float::INFINITY) key = normalize_class(klass) begin @limits.fetch(key) rescue return default_limit end end |