class Opto::Resolvers::File

Read the value from a file, path defined in hint.

Public Instance Methods

file_path() click to toggle source
# File lib/opto/resolvers/file_content.rb, line 10
def file_path
  if hint.kind_of?(String)
    hint
  elsif hint.kind_of?(Hash) && (hint['path'] || hint[:path])
    hint['path'] || hint[:path]
  else
    raise ArgumentError, "File path not set"
  end
end
ignore_errors?() click to toggle source
# File lib/opto/resolvers/file_content.rb, line 6
def ignore_errors?
  hint.kind_of?(Hash) && (hint['ignore_errors'] || hint[:ignore_errors])
end
resolve() click to toggle source
# File lib/opto/resolvers/file_content.rb, line 20
def resolve
  if ignore_errors?
    file_path
    ::File.read(file_path) rescue nil
  else
    ::File.read(file_path)
  end
end