bin/console in usable-1.4.0 vs bin/console in usable-2.0.0
- old
+ new
@@ -10,19 +10,22 @@
# require "pry"
# Pry.start
module VersionMixin
def save_version
- "Saving up to #{self.class.usable_config.max_versions} versions to #{self.class.usable_config.table_name}"
+ "Saving up to #{usables.max_versions} versions to #{usables.table_name}"
end
def destroy_version
- "Deleting versions from #{self.class.usable_config.table_name}"
+ "Deleting versions from #{usables.table_name}"
end
end
module Mixin
+ extend Usable
+ usables[:max_versions] = 20
+
def name
"defined by Mixin"
end
def from_mixin
@@ -42,29 +45,40 @@
end
class Model
extend Usable
- usable VersionMixin, only: :save_version do |config|
- config.max_versions = 10
- config.table_name = 'custom_versions'
+ usable VersionMixin, only: :save_version do
+ max_versions 10
+ table_name 'custom_versions'
end
def save
- self.class.usable_method(self, :save_version).call
+ 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, max_versions: 10
+ usable VersionMixin do
+ max_versions 10
+ end
+ usable Nested::Extension
end
Model.usable PersistenceOverride, method: 'prepend'
require "irb"