README.md in usable-2.1.1 vs README.md in usable-2.1.2
- old
+ new
@@ -4,15 +4,15 @@
available to both the module and including class. Allows you to include only the methods you want.
```ruby
module VersionMixin
extend Usable
- usables[:max_versions] = 25
- usables[:table_name] = 'versions'
+ config.max_versions = 25
+ config.table_name = 'versions'
def save_version
- "Saving up to #{usables.max_versions} versions to #{usables.table_name}"
+ "Saving #{usables.max_versions} #{usables.table_name}"
end
def destroy_version
"Deleting versions from #{usables.table_name}"
end
@@ -21,20 +21,19 @@
class Model
extend Usable
usable VersionMixin, only: :save_version do
max_versions 10
- table_name 'custom_versions'
end
def save
save_version
end
end
model = Model.new
-model.save_version # => "Saving up to 10 versions to custom_versions"
+model.save_version # => "Saving 10 versions"
model.destroy_version # => NoMethodError: undefined method `destroy_version' for #<Model:...
```
`Model` now has a `#save_versions` method but no `#destroy_version` method. Usable has effectively mixed in the given module
using `include`. Ruby 2+ offers the `prepend` method, which can be used instead by specifying it as the `:method` option:
@@ -91,10 +90,11 @@
## Module Naming Conventions
Modules with the following names found within the target module's namespace will be automatically used.
-`ClassMethods` - extended onto the target module.
+* `ClassMethods`
+* `InstanceMethods`
## Notes
If the given module is modified by the `:only` option, then Usable will duplicate the module so that it doesn't mutate
it globally. Duplicating a module returns an anonymous module. But anonymous mods in the ancestor list can be confusing.