Class: Attrio::Types::Integer
- Inherits:
-
Base
show all
- Defined in:
- lib/attrio/types/integer.rb
Class Method Summary
collapse
Methods inherited from Base
default_reader_aliases, default_writer_aliases
Class Method Details
.typecast(value, options = {}) ⇒ Object
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/attrio/types/integer.rb', line 6
def self.typecast(value, options = {})
options[:base] ||= 10
begin
return value.to_i(options[:base]) if value.is_a?(String)
return value.to_i
rescue NoMethodError => e
nil
end
end
|
.typecasted?(value, options = {}) ⇒ Boolean
17
18
19
|
# File 'lib/attrio/types/integer.rb', line 17
def self.typecasted?(value, options = {})
value.is_a? ::Integer
end
|