0.0
The project is in a healthy, maintained state
Compose configurations for any class.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

ClassComposer

Basic configuration is relatively simple but tedious to do if done multiple times. throughout a project. The intention of ClassComposer is to DRY up as much of that configuration as possible to allow you to just write code.

Installation

ClassComposer is hosted on RubyGems https://rubygems.org/gems/class_composer

Add this line to your application's Gemfile:

gem 'class_composer'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install class_composer

Usage

Basic Add Composer

add_composer is the driving method behind the composer gem. It will

  • Add a setter Method
  • Add a getter Method
  • Add instance variable
  • Add validation Method

In short, Composer will behave similarly to attr_accessor

Check out Basic Composer for usage details

Usage with Arrays

Composer allows interactions with arrays in a native way. When the allowed type is Array, ClassComposer will add a custom method << to overwrite the native Array method. This ensures that ClassComposer Validations run when adding to the Array.

For more information, check out Array Usage

Freezing Objects

Sometimes you want freeze an instance of a Configuration. Freezing it will make it immutable from changes Users may try to make.

For more information, check out Freezing Class Composer Instances

Complex usage: Composer Blocking

Composer blocking builds on top of the Basic Composer to help with nested Configurations that include ClassCompser::Generator. Nested configuration's allow complex configurations for entire projects to work seamlessly together.

For Examples and use cases, check out Composer Blocking

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bundle exec rspec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/matt-taylor/class_composer.