Sha256: e83c8ed84f589b5dec60d002bece3182ed40daee8464e19d6b19862c5e4f2805

Contents?: true

Size: 720 Bytes

Versions: 3

Compression:

Stored size: 720 Bytes

Contents

module Mongoid::Acts::NestedSet

  module TestDocument

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


    module ClassMethods

      def test_set_dependent_option(val)
        self.acts_as_nested_set_options[:dependent] = val
      end

    end


    module InstanceMethods

      def test_set_attributes(attrs)
        attrs.each do |key, val|
          if Mongoid.allow_dynamic_fields ||
              fields.keys.any? { |k| k.to_s == key.to_s } ||
              associations.any? { |a| a[0].to_s == key.to_s || a[1].foreign_key.to_s == key.to_s }
            @attributes[key] = val
          end
        end
        self
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongoid_nested_set-0.1.2 spec/models/test_document.rb
mongoid_nested_set-0.1.1 spec/models/test_document.rb
mongoid_nested_set-0.1.0 spec/models/test_document.rb