Sha256: 6585974d98e3f0e7311a80efce8549c6d5c35f0eef0b9be58c6154fff09abf9a

Contents?: true

Size: 930 Bytes

Versions: 2

Compression:

Stored size: 930 Bytes

Contents

require "mache/dsl"

module Mache
  # The Node class represents a wrapped HTML page, or fragment. It exposes all
  # methods from the Mache {DSL}, and forwards any Capybara API methods to the
  # {#node} object.
  #
  # @abstract
  class Node
    include DSL

    # The underlying Capybara node object wrapped by this node.
    #
    # @return [Capybara::Node] the node object
    attr_reader :node

    # Returns a new instance of Node.
    #
    # @param node [Capybara::Node] the Capybara node object to wrap
    def initialize(node:)
      @node ||= node
    end

    # Forwards any Capybara API calls to the node object.
    def method_missing(name, *args, &block)
      if @node.respond_to?(name)
        @node.send(name, *args, &block)
      else
        super
      end
    end

    # @!visibility private
    def respond_to_missing?(name, include_private = false)
      @node.respond_to?(name) || super
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mache-2.0.0 lib/mache/node.rb
mache-1.0.1 lib/mache/node.rb