Sha256: 82a5c1485671b9e9cba696292951facf5c027854854d8a190eb4c22d863d39fd

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

# TableSync (development)

## Table of Contents

- [Creation and registration of the new plugin](#creation-and-registration-of-the-new-plugin)

### Creation and registration of the new plugin

* Create a class inherited from `TableSync::Plugins::Abstract` (recommendation: place it in the plugins directory (`lib/plugins/`));
* Implement `.install!` method (`TableSync::Plugins::Abstract.install!`)
* Register the newly created class in plugins ecosystem (`TableSync.register_plugin('plugin_name', PluginClass))`);
* Usage: `TableSync.enable(:plugin_name)` / `TableSync.plugin(:plugin_name)` / `TableSync.load(:plugin_name)` (string name is supported too);

Example:

```ruby
# 1) creation (lib/plugins/global_method.rb)
class TableSync::Plugins::GlobalMethod < TableSync::Plugins::Abstract
  class << self
    # 2) plugin loader method implementation
    def install!
      ::TableSync.extend(Module.new do
        def global_method
          :works!
        end
      end)
    end
  end
end

# 3) plugin registration
TableSync.register('global_method', TableSync::Plugins::GlobalMethod)

# 4) enable registerd plugin
TableSync.plugin(:global_method) # string is supported too
# --- or ---
TableSync.enable(:global_method) # string is supported too
# --- or ---
TableSync.load(:global_method) # string is supported too

# Your new functionality
TableSync.global_method # => :works!
```

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
table_sync-2.3.0 docs/development.md
table_sync-2.2.0 docs/development.md