Module: Stastic::Config

Extended by:
Config
Included in:
Config
Defined in:
lib/stastic/config.rb

Constant Summary collapse

VALID_SETTINGS =
%w(user token name site_id site_root host)

Instance Method Summary collapse

Instance Method Details

#credentials?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/stastic/config.rb', line 12

def credentials?
  exists? && user && token
end

#exists?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/stastic/config.rb', line 8

def exists?
  File.exists?(config_path) || File.exists?(global_path)
end

#resetObject



30
31
32
33
# File 'lib/stastic/config.rb', line 30

def reset
  @config = nil
  @global_config = nil
end

#site_defined?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/stastic/config.rb', line 16

def site_defined?
  credentials? && site_id
end

#update(attrs, scope = nil) ⇒ Object Also known as: add



20
21
22
23
24
25
26
# File 'lib/stastic/config.rb', line 20

def update(attrs, scope = nil)
  if scope == :global
    @global_config = update_config(attrs, global_config, global_path)
  else
    @config = update_config(attrs, config, config_path)
  end
end