Class: CodeUnion::Config::FileAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/codeunion/config.rb

Overview

Reads and writes YAML to the FileSystem

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ FileAdapter

Returns a new instance of FileAdapter.



81
82
83
# File 'lib/codeunion/config.rb', line 81

def initialize(file_path)
  @file_path = file_path
end

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



79
80
81
# File 'lib/codeunion/config.rb', line 79

def file_path
  @file_path
end

Instance Method Details

#to_hashObject Also known as: to_h



90
91
92
93
# File 'lib/codeunion/config.rb', line 90

def to_hash
  ensure_exists!
  YAML.load_file(file_path).dup
end

#write(data) ⇒ Object



85
86
87
88
# File 'lib/codeunion/config.rb', line 85

def write(data)
  ensure_exists!
  write_fearlessly(data)
end