Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeremyf/exercise_options
https://github.com/jeremyf/exercise_options
Last synced: 28 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jeremyf/exercise_options
- Owner: jeremyf
- Created: 2022-09-21T16:17:48.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-26T15:19:19.000Z (over 2 years ago)
- Last Synced: 2024-11-18T12:38:31.570Z (about 1 month ago)
- Language: Ruby
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ExerciseOptions
An experimental gem for making amendments to upstream dependencies.
This project came about when I was working with Samvera's Actor Stack and needed to add additional variables to a few different classes.
## Installation
Install the gem and add to the application's Gemfile by executing:
$ bundle add exercise_options
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install exercise_options
## Usage
```ruby
class MyObject
def initialize(name:)
self.name = name
end
attr_accessor :name
endMyObject.prepend(
ExerciseOptions.for(
default_is_true: true,
conditionally_true_with_receiver: ->(obj) { obj.name == "Hello World" },
)
)obj = MyObject.new(name: "Nobody")
expect(obj.default_is_true).to be_truthy
expect(obj.conditionally_true_with_receiver).to be_falseynext_object = MyObject.new(name: "Hello World", default_is_true: false)
expect(next_object.default_is_true).to be_falsey
expect(next_object.conditionally_true_with_receiver).to be_truthy
```## Development
Let's see if this thing make sense?