Chirrin Chirrion is a gem to manage feature toggle, allowing developers to easily change the software behavior by showing/hiding new features and fixes.
The gem name was inspired by a funny Chapolim Colorado episode called 'Chirrin Chirrion del Diablo', where there was a magic wand that created new things if its bearer used the magic word 'chirrin', and those things were destroyed with the word 'chirrion'.
gem install chirrin-chirrion
require 'chirrin-chirrion'
redis_connection = Redis.new
redis_adapter = ChirrinChirrion::DatabaseAdapters::RedisAdapter.new(redis_connection)
ChirrinChirrion.config(database_adapter: redis_adapter)
ChirrinChirrion.list
# => [#<OpenStruct description="What the toggle does.", active=true, name="toggle_name">]
ChirrinChirrion.add_toggle('new_user_register_validation', {active: true, description: 'When this is active, gender, age and phone number are not required'})
ChirrinChirrion.remove_toggle('new_user_register_validation')
ChirrinChirrion.chirrin!('new_user_register_validation')
ChirrinChirrion.chirrion!('new_user_register_validation')
if ChirrinChirrion.chirrin?('new_user_register_validation')
# new busines rules
else
# old busines rules
end
chirrin_behavior = lambda do
# do a lot of things
{ result: 'of things' }
end
chirrion_behavior = { result: 'old static result' }
ChirrinChirrion.chirrin_chirrion('my_toggle', chirrin_behavior, chirrion_behavior)