Class: Attrio::Types::Boolean
Class Method Summary collapse
- .default_reader_aliases(method_name) ⇒ Object
- .typecast(value, options = {}) ⇒ Object
- .typecasted?(value, options = {}) ⇒ Boolean
Methods inherited from Base
Class Method Details
.default_reader_aliases(method_name) ⇒ Object
21 22 23 |
# File 'lib/attrio/types/boolean.rb', line 21 def self.default_reader_aliases(method_name) super.push("#{method_name}?").flatten.uniq end |
.typecast(value, options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/attrio/types/boolean.rb', line 6 def self.typecast(value, = {}) true_values = [:true] || [:true_values] || ['yes', '1', 1, 'true'] false_values = [:false] || [:false_values] if false_values.present? return Helpers.to_a(false_values).flatten.include?(value) ? false : true else return Helpers.to_a(true_values).flatten.include?(value) ? true : false end end |
.typecasted?(value, options = {}) ⇒ Boolean
17 18 19 |
# File 'lib/attrio/types/boolean.rb', line 17 def self.typecasted?(value, = {}) value.is_a?(TrueClass) || value.is_a?(FalseClass) end |