Class: Omen::Config

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

Overview

Every fact about the app this feature is installed in, so none of its own classes names one. All of them have a default, which is what makes the initializer a host writes optional.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



24
25
26
27
28
29
30
# File 'lib/omen/config.rb', line 24

def initialize
  @reading_role = :reading
  @narrow_role = 'omen_inquirer'
  @claude_model = 'claude-opus-5'
  @maximum_rows = 100
  @schema_path = 'db/schema.rb'
end

Instance Attribute Details

#api_keyObject

The key the Anthropic API is reached with. Left unset, the SDK resolves one of its own.



19
20
21
# File 'lib/omen/config.rb', line 19

def api_key
  @api_key
end

#claude_modelObject

The Claude model a question is asked of.



13
14
15
# File 'lib/omen/config.rb', line 13

def claude_model
  @claude_model
end

#maximum_rowsObject

How many rows of one answer a page will show.



16
17
18
# File 'lib/omen/config.rb', line 16

def maximum_rows
  @maximum_rows
end

#narrow_roleObject

The Postgres role a statement runs as, narrower again than the connection's own.



10
11
12
# File 'lib/omen/config.rb', line 10

def narrow_role
  @narrow_role
end

#notesString

Returns the host's own notes about its data, which its schema cannot state.

Returns:

  • (String)

    the host's own notes about its data, which its schema cannot state.



37
# File 'lib/omen/config.rb', line 37

def notes = @notes ? File.read(@notes) : ''

#reading_roleObject

The Rails connection role a statement is read through. A host has to declare a read-only one: Omen raises rather than falling back to the writing role, which is the point.



7
8
9
# File 'lib/omen/config.rb', line 7

def reading_role
  @reading_role
end

#record_class=(value) ⇒ Object (writeonly)

What a host states as a name or as a path, each of them resolved only when it is wanted.



22
23
24
# File 'lib/omen/config.rb', line 22

def record_class=(value)
  @record_class = value
end

#schema_path=(value) ⇒ Object (writeonly)

What a host states as a name or as a path, each of them resolved only when it is wanted.



22
23
24
# File 'lib/omen/config.rb', line 22

def schema_path=(value)
  @schema_path = value
end

Instance Method Details

#recordClass

A name rather than the class, since nothing is autoloaded while an initializer runs.

Returns:

  • (Class)

    the Active Record whose descendants and connection roles this feature uses.



34
# File 'lib/omen/config.rb', line 34

def record = @record_class ? @record_class.constantize : default_record

#schemaPathname

Returns the file Rails keeps in step with the database, which Claude is shown.

Returns:

  • (Pathname)

    the file Rails keeps in step with the database, which Claude is shown.



40
# File 'lib/omen/config.rb', line 40

def schema = Rails.root.join @schema_path