Skip to content

Commit

Permalink
Hooks + Default User + Online/Offline + EvaluationDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
kp-cat authored Feb 16, 2023
1 parent 9b09bf4 commit 41b2983
Show file tree
Hide file tree
Showing 39 changed files with 2,728 additions and 1,188 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ruby-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-versions: [ 2.4, 2.5, 2.6, 2.7, '3.0' ]
ruby-versions: [ 2.4, 2.5, 2.6, 2.7, '3.0', '3.1' ]
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ require 'configcat'

### 4. Create a *ConfigCat* client instance:
```ruby
configcat_client = ConfigCat.create_client("#YOUR-SDK-KEY#")
configcat_client = ConfigCat.get("#YOUR-SDK-KEY#")
```
> We strongly recommend using the *ConfigCat Client* as a Singleton object in your application.
> We strongly recommend using the *ConfigCat Client* as a Singleton object in your application. The `ConfigCat.get` static factory method constructs singleton client instances for your SDK keys.
### 5. Get your setting value
```ruby
isMyAwesomeFeatureEnabled = configcat_client.get_value("isMyAwesomeFeatureEnabled", false)
if isMyAwesomeFeatureEnabled
do_the_new_thing()
do_the_new_thing
else
do_the_old_thing()
do_the_old_thing
end
```

### 6. Stop *ConfigCat* client on application exit
```ruby
configcat_client.stop()
configcat_client.close
```

## Getting user specific setting values with Targeting
Expand All @@ -55,9 +55,9 @@ user = ConfigCat::User.new("#USER-IDENTIFIER#")

isMyAwesomeFeatureEnabled = configcat_client.get_value("isMyAwesomeFeatureEnabled", false, user)
if isMyAwesomeFeatureEnabled
do_the_new_thing()
do_the_new_thing
else
do_the_old_thing()
do_the_old_thing
end
```

Expand Down
260 changes: 127 additions & 133 deletions lib/configcat.rb

Large diffs are not rendered by default.

99 changes: 0 additions & 99 deletions lib/configcat/autopollingcachepolicy.rb

This file was deleted.

23 changes: 19 additions & 4 deletions lib/configcat/configcache.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
require 'configcat/interfaces'

module ConfigCat
class NullConfigCache < ConfigCache
def initialize
@value = {}
end

def get(key)
return nil
end

def set(key, value)
# do nothing
end
end

class InMemoryConfigCache < ConfigCache
def initialize()
@_value = {}
attr_reader :value
def initialize
@value = {}
end

def get(key)
return @_value.fetch(key, nil)
return @value.fetch(key, nil)
end

def set(key, value)
@_value[key] = value
@value[key] = value
end
end
end
Loading

0 comments on commit 41b2983

Please sign in to comment.