Class: ModelWarnings
- Inherits:
-
Hash
- Object
- Hash
- ModelWarnings
- Defined in:
- lib/warn_if/model_warnings.rb
Instance Method Summary collapse
- #all ⇒ Object
- #clear ⇒ Object
- #clear? ⇒ Boolean
-
#initialize ⇒ ModelWarnings
constructor
A new instance of ModelWarnings.
- #new ⇒ Object
- #with_severity(severity) ⇒ Object
Constructor Details
#initialize ⇒ ModelWarnings
Returns a new instance of ModelWarnings.
2 3 4 5 6 |
# File 'lib/warn_if/model_warnings.rb', line 2 def initialize super self[:base] = [] self end |
Instance Method Details
#all ⇒ Object
8 9 10 |
# File 'lib/warn_if/model_warnings.rb', line 8 def all values.flatten end |
#clear ⇒ Object
12 13 14 15 16 |
# File 'lib/warn_if/model_warnings.rb', line 12 def clear # self.keys.each {|k| self[k] = []} super self[:base] = [] end |
#clear? ⇒ Boolean
18 19 20 |
# File 'lib/warn_if/model_warnings.rb', line 18 def clear? keys == [:base] && self[:base] == [] end |
#new ⇒ Object
22 23 24 |
# File 'lib/warn_if/model_warnings.rb', line 22 def new all.select {|w| w.new?} end |
#with_severity(severity) ⇒ Object
26 27 28 |
# File 'lib/warn_if/model_warnings.rb', line 26 def with_severity(severity) all.select {|w| w.severity == severity} end |