Sha256: 1afe9e5211681f5d3043fb696379988fbc696726efa6eb5aad1df82098119361

Contents?: true

Size: 443 Bytes

Versions: 4

Compression:

Stored size: 443 Bytes

Contents

module Kangaroo
  module DefaultAttributes
    # @private
    def self.included klass
      klass.extend ClassMethods

      klass.before_initialize do
        return true if persisted?

        self.class.default_attributes.each do |name, value|
          write_attribute name, value
        end
      end
    end

    module ClassMethods
      def default_attributes
        default_get :fields => attribute_names
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kangaroo-0.0.3 lib/kangaroo/model/default_attributes.rb
kangaroo-0.0.2 lib/kangaroo/model/default_attributes.rb
kangaroo-0.0.1.pre2 lib/kangaroo/model/default_attributes.rb
kangaroo-0.0.1.pre lib/kangaroo/model/default_attributes.rb