Class: Mache::Node Abstract

Inherits:
Object
  • Object
show all
Includes:
DSL
Defined in:
lib/mache/node.rb

Overview

This class is abstract.

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.

Direct Known Subclasses

Page

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DSL

included

Constructor Details

#initialize(node:) ⇒ Node

Returns a new instance of Node.

Parameters:

  • node (Capybara::Node)

    a Capybara node object to wrap



20
21
22
# File 'lib/mache/node.rb', line 20

def initialize(node:)
  @node ||= node
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object

Forwards any Capybara API calls to the node object.



25
26
27
28
29
30
31
# File 'lib/mache/node.rb', line 25

def method_missing(name, *args, &block)
  if @node.respond_to?(name)
    @node.send(name, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#nodeCapybara::Node (readonly)

The underlying Capybara node object wrapped by this instance.

Returns:

  • (Capybara::Node)

    a node object



15
16
17
# File 'lib/mache/node.rb', line 15

def node
  @node
end