Sha256: fa9125c91caa1cae991503db7fbccb44a74fc6f93553a9b743a018a09ae49bfa

Contents?: true

Size: 614 Bytes

Versions: 14

Compression:

Stored size: 614 Bytes

Contents

module DeepCover
  module Node::Mixin
    module ChildCanBeEmpty
      class << self
        attr_accessor :last_empty_position # Ugly hack to pass info from Handler to constructor
        def included(base)
          base.has_child_handler('%{name}_can_be_empty')
        end
      end

      def remap_child(child, name=raise)
        if child == nil
          if (ChildCanBeEmpty.last_empty_position = child_can_be_empty(child, name))
            return Node::EmptyBody
          end
        end
        super
      end

      def child_can_be_empty(_child, _name=nil)
        false
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
deep-cover-0.1.14 lib/deep_cover/node/mixin/child_can_be_empty.rb
deep-cover-0.1.13 lib/deep_cover/node/mixin/child_can_be_empty.rb
deep-cover-0.1.12 lib/deep_cover/node/mixin/child_can_be_empty.rb
deep-cover-0.1.11 lib/deep_cover/node/mixin/child_can_be_empty.rb
deep-cover-0.1.10 lib/deep_cover/node/mixin/child_can_be_empty.rb
deep-cover-0.1.9 lib/deep_cover/node/mixin/child_can_be_empty.rb
deep-cover-0.1.8 lib/deep_cover/node/mixin/child_can_be_empty.rb
deep-cover-0.1.7 lib/deep_cover/node/mixin/child_can_be_empty.rb
deep-cover-0.1.6 lib/deep_cover/node/mixin/child_can_be_empty.rb
deep-cover-0.1.5 lib/deep_cover/node/mixin/child_can_be_empty.rb
deep-cover-0.1.4 lib/deep_cover/node/mixin/child_can_be_empty.rb
deep-cover-0.1.3 lib/deep_cover/node/mixin/child_can_be_empty.rb
deep-cover-0.1.2 lib/deep_cover/node/mixin/child_can_be_empty.rb
deep-cover-0.1.1 lib/deep_cover/node/mixin/child_can_be_empty.rb