Module: ChirrinChirrion
- Defined in:
- lib/chirrin-chirrion.rb,
lib/chirrin-chirrion/errors.rb,
lib/chirrin-chirrion/version.rb,
lib/chirrin-chirrion/database_adapters/redis_adapter.rb
Defined Under Namespace
Modules: DatabaseAdapters, Errors
Constant Summary collapse
- VERSION =
"0.3.0"
Class Method Summary collapse
-
.add_toggle(toggle_name, toggle_info = {}) ⇒ Object
Adds a toggle to the database.
-
.chirrin!(toggle_name) ⇒ Object
Makes a toggle active (the toggle must already be registered).
-
.chirrin?(toggle_name) ⇒ Boolean
Checks if a toggle active (the toggle must already be registered).
-
.chirrin_chirrion(toggle_name, for_chirrin, for_chirrion) ⇒ Object
Executes determinated action if the toggle chirrin, if not executes another achtion.
-
.chirrion!(toggle_name) ⇒ Object
Makes a toggle inactive.
-
.chirrion?(toggle_name) ⇒ Boolean
Checks if a toggle inactive.
-
.config(options) ⇒ Object
Defines the configuration for Chirrin Chirrion.
-
.remove_toggle(toggle_name) ⇒ Object
Removes a toggle from the database.
Class Method Details
.add_toggle(toggle_name, toggle_info = {}) ⇒ Object
Adds a toggle to the database
ChirrinChirrion.add_toggle(‘my_active_feature’) ChirrinChirrion.add_toggle(‘my_inactive_feature’)
31 32 33 |
# File 'lib/chirrin-chirrion.rb', line 31 def self.add_toggle(toggle_name, toggle_info = {}) database_adapter.add_toggle(toggle_name, toggle_info) end |
.chirrin!(toggle_name) ⇒ Object
Makes a toggle active (the toggle must already be registered)
ChirrinChirrion.chirrin!(‘my_inactive_feature’) ChirrinChirrion.chirrin?(‘my_inactive_feature’) #=> true
49 50 51 |
# File 'lib/chirrin-chirrion.rb', line 49 def self.chirrin!(toggle_name) database_adapter.activate!(toggle_name) end |
.chirrin?(toggle_name) ⇒ Boolean
Checks if a toggle active (the toggle must already be registered)
ChirrinChirrion.chirrin?(‘my_active_feature’) #=> true ChirrinChirrion.chirrin?(‘my_inactive_feature’) #=> false ChirrinChirrion.chirrin?(‘my_unregistered_toggle’) #=> false
68 69 70 |
# File 'lib/chirrin-chirrion.rb', line 68 def self.chirrin?(toggle_name) database_adapter.active?(toggle_name) end |
.chirrin_chirrion(toggle_name, for_chirrin, for_chirrion) ⇒ Object
Executes determinated action if the toggle chirrin, if not executes another achtion
ChirrinChirrion.chirrin(‘mult_for_2’) ten_numbers = (1..10).to_a actiction_for_chirrin = lambda { ten_numbers.map{|number| number * 2 } } actiction_for_chirrion = lambda { ten_numbers.map{|number| number * 4 } } ChirrinChirrion.chirrin_chirrion(‘mult_for_2’, action_for_chirrin, action_for_chirrion) #=> [4, 8, 12, 16, 20, 24, 28, 32, 36, 40] ChirrinChirrion.chirrin(‘mult_for_2’) ChirrinChirrion.chirrin_chirrion(‘mult_for_2’, action_for_chirrin, action_for_chirrion) #=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
92 93 94 95 96 97 98 |
# File 'lib/chirrin-chirrion.rb', line 92 def self.chirrin_chirrion(toggle_name, for_chirrin, for_chirrion) if chirrin?(toggle_name) for_chirrin.respond_to?(:call) ? for_chirrin.call : for_chirrin else for_chirrion.respond_to?(:call) ? for_chirrion.call : for_chirrion end end |
.chirrion!(toggle_name) ⇒ Object
Makes a toggle inactive
ChirrinChirrion.chirrion!(‘my_active_feature’) ChirrinChirrion.chirrion?(‘my_active_feature’) #=> false
58 59 60 |
# File 'lib/chirrin-chirrion.rb', line 58 def self.chirrion!(toggle_name) database_adapter.inactivate!(toggle_name) end |
.chirrion?(toggle_name) ⇒ Boolean
Checks if a toggle inactive
ChirrinChirrion.chirrion?(‘my_active_feature’) #=> false ChirrinChirrion.chirrion?(‘my_inactive_feature’) #=> true ChirrinChirrion.chirrin?(‘my_unregistered_toggle’) #=> true
78 79 80 |
# File 'lib/chirrin-chirrion.rb', line 78 def self.chirrion?(toggle_name) database_adapter.inactive?(toggle_name) end |
.config(options) ⇒ Object
Defines the configuration for Chirrin Chirrion. The config are:
- database_adapter, an adapter which wrap the database management to provide the correct service
redis_connection = Redis.new redis_adapter = RedisAdapter.new(redis_connection) ChirrinChirrion.config(database_adapter: redis_adapter)
16 17 18 |
# File 'lib/chirrin-chirrion.rb', line 16 def self.config() @database_adapter = [:database_adapter] end |
.remove_toggle(toggle_name) ⇒ Object
Removes a toggle from the database
ChirrinChirrion.remove_toggle(‘my_active_feature’) ChirrinChirrion.remove_toggle(‘my_inactive_feature’)
40 41 42 |
# File 'lib/chirrin-chirrion.rb', line 40 def self.remove_toggle(toggle_name) database_adapter.remove_toggle(toggle_name) end |