Sha256: c28756f6bf6f32f54b9f8ccdab75c6768c105aefdc1f4af1be80dac7f909b6d0

Contents?: true

Size: 386 Bytes

Versions: 1

Compression:

Stored size: 386 Bytes

Contents

require "transformable/version"

module Transformable

  def self.included(base)
    base.extend ClassMethods
  end


  module ClassMethods
    def clean(attr, &blk)

      define_method "#{attr}=" do |value|
	new_value = yield(value)
	instance_variable_set("@#{attr}", new_value)
	write_attribute(attr, new_value) if respond_to? :write_attribute
	new_value
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
transformable-0.0.1 lib/transformable.rb