Method: Feature.set_repository

Defined in:
lib/feature.rb

.set_repository(repository, refresh = false) ⇒ Object

Set the feature repository The given repository has to respond to method ‘active_features’ with an array of symbols

Parameters:

  • the repository to get the features from

  • (defaults to: false)

    optional (default: false) - auto refresh or refresh after given number of seconds



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/feature.rb', line 36

def self.set_repository(repository, refresh = false)
  unless repository.respond_to?(:active_features)
    raise ArgumentError, 'given repository does not respond to active_features'
  end

  @perform_initial_refresh = true
  @repository = repository
  if [true, false].include?(refresh)
    @auto_refresh = refresh
  else
    @auto_refresh = false
    @refresh_after = refresh
    @next_refresh_after = Time.now + @refresh_after
  end
end