README.md in usable-3.3.0 vs README.md in usable-3.4.0
- old
+ new
@@ -1,12 +1,22 @@
# Usable [![Gem Version](https://badge.fury.io/rb/usable.svg)](http://badge.fury.io/rb/usable) [![Build Status](https://travis-ci.org/ridiculous/usable.svg)](https://travis-ci.org/ridiculous/usable) [![Code Climate](https://codeclimate.com/github/ridiculous/usable/badges/gpa.svg)](https://codeclimate.com/github/ridiculous/usable)
Usable provides an elegant way to mount and configure your modules. Class level settings can be configured on a per module basis,
available to both the module and including class. Allows you to include only the methods you want.
-Configure a module to be usable
+## Installation
+
+Add this line to your application's Gemfile:
+
```ruby
+gem 'usable'
+```
+
+## Usage
+
+Configure a module to have "usable" defaults:
+```ruby
module VersionMixin
extend Usable
config do
max_versions 25
@@ -22,11 +32,11 @@
"Deleting versions from #{usables.table_name}"
end
end
```
-Include the module into a class using `usable`, which will copy over any configuration options
+Include the module into a class using `usable`, which will copy over the configs:
```ruby
class Model
extend Usable
usable VersionMixin, only: :save_version do
@@ -116,20 +126,37 @@
```ruby
Mixin => MixinUsed
```
-## Installation
+## Tips and Tricks
-Add this line to your application's Gemfile:
+#### __3.4__ _-(unreleased)_
+Import just a module's constants:
+
```ruby
-gem 'usable'
+usable ExampleMod, only: :constants
```
-## Tips and Tricks
+Currently works with `usable ExampleMod, only: []` since version 2.0
+#### __since version 3.3__ _- (not required)_
+The `Usable::Struct` function is available for creating value objects with defaults. If you `require "usable/struct"` the
+class function is available to create classes:
+
+```ruby
+class Route < Usable::Struct(paths: %w[api v2 v3])
+end
+
+Route.usables.to_h # => {:paths=>["api", "v2", "v3"]}
+Route.new.paths # => ["api", "v2", "v3"]
+Route.new(paths: nil).paths # => nil
+```
+
+#### __since version 2.0__
+
When usable modules define the same config setting, the last one mounted takes precedence. Fortunately,
Usable also "stacks" config settings by namespacing them:
```ruby
module Robot
@@ -152,15 +179,9 @@
end
User.usables.speak # => "beep bop"
User.usables.human.speak # => "Hello"
User.usables.robot.speak # => "beep bop"
-```
-
-Import just a module's constants with this little trick:
-
-```ruby
-usable ExampleMod, only: []
```
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.