Class: TableWarnings::Size
- Inherits:
-
Object
- Object
- TableWarnings::Size
- Defined in:
- lib/table_warnings/size.rb
Instance Attribute Summary collapse
-
#approximate_size ⇒ Object
readonly
Returns the value of attribute approximate_size.
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
-
#initialize(table, approximate_size, options = {}) ⇒ Size
constructor
A new instance of Size.
- #messages ⇒ Object
Constructor Details
#initialize(table, approximate_size, options = {}) ⇒ Size
Returns a new instance of Size.
7 8 9 10 11 |
# File 'lib/table_warnings/size.rb', line 7 def initialize(table, approximate_size, = {}) @table = table @approximate_size = approximate_size @conditions = [:conditions] || {} end |
Instance Attribute Details
#approximate_size ⇒ Object (readonly)
Returns the value of attribute approximate_size.
4 5 6 |
# File 'lib/table_warnings/size.rb', line 4 def approximate_size @approximate_size end |
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
5 6 7 |
# File 'lib/table_warnings/size.rb', line 5 def conditions @conditions end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
3 4 5 |
# File 'lib/table_warnings/size.rb', line 3 def table @table end |
Instance Method Details
#messages ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/table_warnings/size.rb', line 13 def current_count = effective_count unless allowed_size.include? current_count if conditions.empty? "Row count is expected to be #{allowed_size.to_s}, but is #{current_count}" else "Row count with conditions #{conditions.inspect} is expected to be #{allowed_size.to_s}, but is #{current_count}" end end end |