Sha256: fd78aed44c8144caa83d3d643d23f9af7eb6fd1b3e8d0a6950f7810116f70fa3

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# encoding: utf-8

class AbstractMapper

  # The abstract class that describes the rule to be applied to sole nodes.
  #
  # The subclass should implement two instance methods:
  #
  # * `#optimize?` to check if the optimization should be applied to the node
  # * `#optimize` that should return the optimized node
  #
  # @example
  #   class RemoveEmptyList < AbstractMapper::SoleRule
  #     def optimize?
  #       node.is_a?(List) && node.empty?
  #     end
  #
  #     def optimize
  #     end
  #   end
  #
  # @abstract
  #
  # @api public
  #
  class SoleRule < Rule

    # @private
    def self.composer
      :filter
    end
    private_class_method :composer

    # @!attribute [r] node
    #
    # @return [AbstractMapper::Node] The node to be optimized
    #
    attr_reader :node

    # @!scope class
    # @!method new(node)
    # Creates a rule applied to the sole node
    #
    # @param [AbstractMapper::Node] node
    #
    # @return [AbstractMapper::Rule]

    # @private
    def initialize(node)
      @node = node
      super
    end

  end # class SoleRule

end # class AbstractMapper

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
abstract_mapper-0.0.2 lib/abstract_mapper/sole_rule.rb