Class: ConfigCat::ConfigEntry

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#configObject

Returns the value of attribute config.



9
10
11
# File 'lib/configcat/configentry.rb', line 9

def config
  @config
end

#etagObject

Returns the value of attribute etag.



9
10
11
# File 'lib/configcat/configentry.rb', line 9

def etag
  @etag
end

#fetch_timeObject

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

Returns:

  • (Boolean)


26
27
28
# File 'lib/configcat/configentry.rb', line 26

def empty?
  self == ConfigEntry::EMPTY
end

#to_jsonObject



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