Sha256: 2d60cb2fe030fd8550d1a211c7d0cc692e82d05e4aaee1b65141aeb68cdd93c8

Contents?: true

Size: 757 Bytes

Versions: 1

Compression:

Stored size: 757 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|
          key = key.to_s
          if Mongoid.allow_dynamic_fields ||
              fields.keys.any? { |k| k.to_s == key } ||
              associations.any? { |a| a[0].to_s == key || a[1].foreign_key.to_s == key }
            @attributes[key] = self.typed_value_for(key, val)
          end
        end
        self
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid_nested_set-0.1.3 spec/models/test_document.rb