Sha256: 04a8a71f83a9a0b91c8c769b52b35571f160f6234390d20e1663c471780dbc70

Contents?: true

Size: 520 Bytes

Versions: 3

Compression:

Stored size: 520 Bytes

Contents

module RMXSetAttributes

  def self.included(klass)
    klass.send(:include, InstanceMethods)
    klass.send(:extend, ClassMethods)
  end

  module InstanceMethods

    def after_attributes_set
    end

    def attributes=(attrs={})
      keys = [] + attrs.keys
      while key = keys.pop
        value = attrs[key]
        self.send("#{key}=", value)
      end
      after_attributes_set
    end

  end

  module ClassMethods

    def create(opts={})
      x = new
      x.attributes = opts
      x
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rmx-0.6.2 lib/motion/RMXSetAttributes.rb
rmx-0.6.1 lib/motion/RMXSetAttributes.rb
rmx-0.6.0 lib/motion/RMXSetAttributes.rb