Sha256: f82e3c1797d510d445238a79970a04d0dc164dbdb104c757a6784deabfb8becb

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

#!/usr/bin/env ruby

require "bundler/setup"
require "usable"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start

module VersionMixin
  def save_version
    "Saving up to #{usables.max_versions} versions to #{usables.table_name}"
  end

  def destroy_version
    "Deleting versions from #{usables.table_name}"
  end
end

module Mixin
  extend Usable
  usables[:max_versions] = 20

  def name
    "defined by Mixin"
  end
end

class Model
  extend Usable

  usable VersionMixin, only: :save_version do
    max_versions 10
    table_name 'custom_versions'
  end

  def save
    usable_method(:save_version).call
  end
end

module PersistenceOverride
  def save
    'nope'
  end
end

module Nested
  module Extension
    def go
      'going'
    end
  end
end

class Example
  extend Usable
  usable Mixin
  usable VersionMixin do
    max_versions 10
  end
  usable Nested::Extension
end

Model.usable PersistenceOverride, method: 'prepend'

require "irb"

IRB.start

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
usable-2.1.3 bin/console
usable-2.1.2 bin/console
usable-2.1.1 bin/console
usable-2.1.0 bin/console