Class: Relish::OptionsFile

Inherits:
Object
  • Object
show all
Defined in:
lib/relish/options_file.rb

Overview

Represents a .relish file

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ OptionsFile

Returns a new instance of OptionsFile.



9
10
11
# File 'lib/relish/options_file.rb', line 9

def initialize(path)
  @path = path
end

Instance Method Details

#==(other) ⇒ Object



27
28
29
# File 'lib/relish/options_file.rb', line 27

def == (other)
  options == other
end

#[](key) ⇒ Object



23
24
25
# File 'lib/relish/options_file.rb', line 23

def [](key)
  options[key]
end

#merge(other) ⇒ Object



31
32
33
# File 'lib/relish/options_file.rb', line 31

def merge(other)
  options.merge(other.options)
end

#optionsObject

Stored options as a hash



36
37
38
# File 'lib/relish/options_file.rb', line 36

def options
  @options ||= current_options
end

#store(options) ⇒ Object

Store the given options into the file. Existing options with the same keys  will be overwritten.



15
16
17
18
19
20
21
# File 'lib/relish/options_file.rb', line 15

def store(options)
  @options = self.options.merge(options)
  FileUtils.touch(@path)
  File.open(@path, 'w') do |file|
    YAML.dump(@options, file)
  end
end