<commit_before># Direction

Enforce better encapsulation by returning self from commands.

Thanks to <NAME> for the inspiration.

## Usage

Provide a feature like the Forwardable library, but set the return value to self.

It provides a class level "command" method to do message forwarding.

```ruby
class SomeClass
  extend Direction

  command [:name, :id] => :collaborator, [:color, :type] => :partner
end
```

This will define methods on instances that forward to the provided receiver while enforcing encapsulation of the relationship between objects.


## Installation

Add this line to your application's Gemfile:

    gem 'direction'

And then execute:

    $ bundle

Or install it yourself as:
<commit_msg>update docs example commands and how they work<commit_after># Direction

Enforce better encapsulation by returning self from commands.

Thanks to <NAME> for the inspiration.

## Usage

Provide a feature like the Forwardable library, but set the return value to self.

It provides a class level "command" method to do message forwarding.

```ruby
class Person
  extend Direction

  command [:print_address => :home

  attr_accessor :home
end

class Home
  def print_address(template)
    template << "... the address.."
  end
end

template = STDOUT
person = Person.new
person.home = Home.new
#commands won't leak internal structure and return the receiver of the command
person.print_address(template) #=> person

```

This will define methods on instances that forward to the provided receiver while enforcing encapsulation of the relationship between objects.


## Installation

Add this line to your application's Gemfile:

    gem 'direction'

And then execute:

    $ bundle

Or install it yourself as:

{'fraction_non_alphanumeric': 0.06384213580963435, 'fraction_numerical': 0.0, 'mean_word_length': 4.27217125382263, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7090597', 'n_tokens_mistral': 479, 'n_tokens_neox': 443, 'n_words': 222}