module Pod4::TypeCasting::ClassMethods
Public Instance Methods
encoding()
click to toggle source
# File lib/pod4/typecasting.rb, line 152 def encoding; nil; end
force_encoding(enc)
click to toggle source
# File lib/pod4/typecasting.rb, line 147 def force_encoding(enc) raise Pod4Error, "Bad encoding" unless enc.kind_of? Encoding define_class_method(:encoding){enc} end
typecast(*args)
click to toggle source
# File lib/pod4/typecasting.rb, line 154 def typecast(*args) options = args.pop raise Pod4Error, "Bad Type" \ unless options.keys.include?(:use) || TYPES.include?(options[:as]) raise Pod4Error, "Bad Typecasting" unless options.is_a?(Hash) \ && options.keys.any?{|o| %i|as use|.include? o} \ && args.size >= 1 # Modify self.typecasts to look like: {foo: {as: Date}, bar: {as: Time, strict: true}, ...} c = typecasts.dup args.each do |f| raise Pod4Error, "Unknown column '#{f}'" unless columns.include?(f) c[f] = options end define_class_method(:typecasts) {c} end
typecasts()
click to toggle source
# File lib/pod4/typecasting.rb, line 173 def typecasts; {}; end