Sha256: 8f15ade40edea540de784726e979f18bf6a41a213e6e2e696d577ee79d3aea9e

Contents?: true

Size: 644 Bytes

Versions: 1

Compression:

Stored size: 644 Bytes

Contents

module Spree
  #
  # This module defines common behavior for all the Models
  #
  module Model
    extend MotionSupport::Concern

    module ClassMethods
      #
      # Define the properties or attributes of the model.
      #
      def define_model_attributes(*attrs)
        define_method :attributes do
          attrs
        end

        attrs.each do |attr|
          attr_accessor attr
        end
      end
    end

    #
    # The initializer receives a hash with the attributes
    #
    def initialize(attributes = {})
      self.attributes.each do |attr|
        send("#{attr}=", attributes[attr.to_s])
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree-wrap-0.0.2 motion/spree/model.rb