Class: DatabaseReader
- Inherits:
-
Object
- Object
- DatabaseReader
- Extended by:
- Forwardable
- Defined in:
- lib/database_reader.rb
Defined Under Namespace
Classes: Error, NotFoundError
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Class Method Summary collapse
Instance Method Summary collapse
- #extensions ⇒ Object
-
#initialize(path:, query: nil) ⇒ DatabaseReader
constructor
A new instance of DatabaseReader.
Constructor Details
#initialize(path:, query: nil) ⇒ DatabaseReader
Returns a new instance of DatabaseReader.
11 12 13 14 |
# File 'lib/database_reader.rb', line 11 def initialize(path:, query: nil) @path = Pathname.new(path) @query = query || default_query end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
44 45 46 |
# File 'lib/database_reader.rb', line 44 def path @path end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
44 45 46 |
# File 'lib/database_reader.rb', line 44 def query @query end |
Class Method Details
.default_query ⇒ Object
47 48 49 50 51 |
# File 'lib/database_reader.rb', line 47 def default_query <<~SQL SELECT * FROM ItemTable WHERE key LIKE 'extensionsIdentifiers/enabled' SQL end |
Instance Method Details
#extensions ⇒ Object
18 19 20 21 22 |
# File 'lib/database_reader.rb', line 18 def extensions @extensions ||= JSON.parse(query_extensions.dig(0, 1) || raise(NotFoundError, "Unexpected query result #{query_extensions}")) .map { |ext| ext['id'] } end |