Class: ConfigCat::ConfigEntry
- Inherits:
-
Object
- Object
- ConfigCat::ConfigEntry
- Defined in:
- lib/configcat/configentry.rb
Constant Summary collapse
- CONFIG =
'config'- ETAG =
'etag'- FETCH_TIME =
'fetch_time'- EMPTY =
ConfigEntry.new(etag: 'empty')
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#etag ⇒ Object
Returns the value of attribute etag.
-
#fetch_time ⇒ Object
Returns the value of attribute fetch_time.
Class Method Summary collapse
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(config = {}, etag = '', fetch_time = Utils::DISTANT_PAST) ⇒ ConfigEntry
constructor
A new instance of ConfigEntry.
- #to_json ⇒ Object
Constructor Details
#initialize(config = {}, etag = '', fetch_time = Utils::DISTANT_PAST) ⇒ ConfigEntry
Returns a new instance of ConfigEntry.
11 12 13 14 15 |
# File 'lib/configcat/configentry.rb', line 11 def initialize(config = {}, etag = '', fetch_time = Utils::DISTANT_PAST) @config = config @etag = etag @fetch_time = fetch_time end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
9 10 11 |
# File 'lib/configcat/configentry.rb', line 9 def config @config end |
#etag ⇒ Object
Returns the value of attribute etag.
9 10 11 |
# File 'lib/configcat/configentry.rb', line 9 def etag @etag end |
#fetch_time ⇒ Object
Returns the value of attribute fetch_time.
9 10 11 |
# File 'lib/configcat/configentry.rb', line 9 def fetch_time @fetch_time end |
Class Method Details
.create_from_json(json) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/configcat/configentry.rb', line 17 def self.create_from_json(json) return ConfigEntry::EMPTY if json.nil? return ConfigEntry.new( config = json.fetch(CONFIG, {}), etag = json.fetch(ETAG, ''), fetch_time = json.fetch(FETCH_TIME, Utils::DISTANT_PAST) ) end |
Instance Method Details
#empty? ⇒ Boolean
26 27 28 |
# File 'lib/configcat/configentry.rb', line 26 def empty? self == ConfigEntry::EMPTY end |
#to_json ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/configcat/configentry.rb', line 30 def to_json { CONFIG => config, ETAG => etag, FETCH_TIME => fetch_time } end |