Class: Donjon::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/donjon/settings.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = nil) ⇒ Settings

Returns a new instance of Settings.



7
8
9
10
# File 'lib/donjon/settings.rb', line 7

def initialize(path = nil)
  @path = path || _default_path
  @data = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/donjon/settings.rb', line 16

def method_missing(method_name, *args, &block)
  if method_name.to_s.end_with?('=')
    set(method_name.to_s.chop, *args)
  else
    get(method_name.to_s, *args)
  end
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/donjon/settings.rb', line 5

def path
  @path
end

Instance Method Details

#configured?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/donjon/settings.rb', line 12

def configured?
  user_name && private_key && vault_path
end

#respond_to?(method_name) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/donjon/settings.rb', line 24

def respond_to?(method_name)
  !!(method_name.to_s =~ /[a-z][a-z_]*=?/)
end