Class: Attrio::Types::Symbol

Inherits:
Base show all
Defined in:
lib/attrio/types/symbol.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
# File 'lib/attrio/types/symbol.rb', line 6

def self.typecast(value, options = {})
  begin
    value = value.underscore if options[:underscore].present?
    value.to_sym
  rescue NoMethodError => e
    nil
  end
end

.typecasted?(value, options = {}) ⇒ Boolean

Returns:



15
16
17
# File 'lib/attrio/types/symbol.rb', line 15

def self.typecasted?(value, options = {})
  value.is_a? ::Symbol
end