summaryrefslogtreecommitdiff
path: root/docs/Ruby-API.md
diff options
context:
space:
mode:
authorWild Kat <wk@users.noreply.github.com>2018-06-17 20:17:56 +0200
committerGitHub <noreply@github.com>2018-06-17 20:17:56 +0200
commit81b0b57ff91c5578bbdc8bf239cd6f2853932fbd (patch)
treee478f10cdef5f8e91272745db4ba80d023b563aa /docs/Ruby-API.md
parentbe3e9638a4cb6dc5f369a013677d58eb56ccac11 (diff)
add monkey patching to ruby API docs (#1406)
Diffstat (limited to 'docs/Ruby-API.md')
-rw-r--r--docs/Ruby-API.md35
1 files changed, 33 insertions, 2 deletions
diff --git a/docs/Ruby-API.md b/docs/Ruby-API.md
index a9963b3..f3f488a 100644
--- a/docs/Ruby-API.md
+++ b/docs/Ruby-API.md
@@ -43,6 +43,8 @@ it at least once is required for a model to work.
The block may contain commands to change some behaviour for the given methods
(e.g. calling `post_login` to disable the pager).
+Supports [monkey patching](#monkey-patching).
+
#### `cmd`
Is used to specify commands that should be executed on a model in order to
@@ -75,6 +77,8 @@ string.
Execution order is `:all`, `:secret`, and lastly the command specific block, if
given.
+Supports [monkey patching](#monkey-patching).
+
#### `comment`
Called with a single string containing the string to prepend for comments in
@@ -99,6 +103,8 @@ The passed data is replaced by the return value of the block.
`expect` can be used to, for example, strip escape sequences from output before
it's further processed.
+Supports [monkey patching](#monkey-patching).
+
### At the second level
The following methods are available:
@@ -119,7 +125,11 @@ Used inside `cfg` invocations to specify commands to run once Oxidized has
logged in to the device. Takes one argument that is either a block (taking zero
parameters) or a string containing a command to execute.
-This allows `post_login` to be used for any model-specific items prior to running the regular commands. This could include disabling the output pager or timestamp outputs that would cause constant differences.
+This allows `post_login` to be used for any model-specific items prior to
+running the regular commands. This could include disabling the output pager
+or timestamp outputs that would cause constant differences.
+
+Supports [monkey patching](#monkey-patching).
#### `pre_logout`
@@ -127,9 +137,30 @@ Used to specify commands to run before Oxidized closes the connection to the
device. Takes one argument that is either a block (taking zero parameters) or a
string containing a command to execute.
-This allows `pre_logout` to be used to 'undo' any changes that may have been needed via `post_login` (restore pager output, etc.)
+This allows `pre_logout` to be used to 'undo' any changes that may have been
+needed via `post_login` (restore pager output, etc.)
+
+Supports [monkey patching](#monkey-patching).
#### `send`
Usually used inside `expect` or blocks passed to `post_login`/`pre_logout`.
Takes a single parameter: a string to be sent to the device.
+
+### Monkey patching
+
+Several model blocks accept behavior-modifying arguments that make monkey
+patching existing blocks easier. This is primarily useful when a user-supplied
+model aims to override or extend existing behavior of a model included in Oxidized.
+
+This functionality is supported by `cfg`, `cmd`, `pre_*`, `post_*`, and `expect`
+blocks.
+
+#### `clear: true`
+
+Resets the existing block, allowing the user to completely override its contents.
+
+#### `prepend: true`
+
+Ensures that the contents of the block are prepended, rather than appended (the
+default) to an existing block.