Sha256: 05f9696c5d277f53dd3213df98ca641190deb33e85e510e9a5e0c53ca912dd47
Contents?: true
Size: 792 Bytes
Versions: 1
Compression:
Stored size: 792 Bytes
Contents
module ConfigureMe class Setting attr_reader :name, :type, :default def initialize(owner, name, type, *args) options = args.extract_options! @owner, @name, @type = owner, name.to_s, type @default = options.key?(:default) ? options[:default] : nil end def define_methods! @owner.define_attribute_methods(true) end def convert(value) case type when :string then value when :text then value when :integer then value.to_i rescue value ? 1 : 0 when :float then value.to_f when :date then ActiveRecord::ConnectionAdapters::Column.string_to_date(value) when :boolean then ActiveRecord::ConnectionAdapters::Column.value_to_boolean(value) else value end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
configure_me-0.3.2 | lib/configure_me/setting.rb |