Class: Boxcars::ActiveRecord
- Inherits:
-
EngineBoxcar
- Object
- Boxcar
- EngineBoxcar
- Boxcars::ActiveRecord
- Defined in:
- lib/boxcars/boxcar/active_record.rb
Overview
A Boxcar that interprets a prompt and executes SQL code to get answers rubocop:disable Metrics/ClassLength
Constant Summary collapse
- ARDESC =
the description of this engine boxcar
"useful for when you need to query a database for an application named %<name>s."
- LOCKED_OUT_MODELS =
%w[ActiveRecord::SchemaMigration ActiveRecord::InternalMetadata ApplicationRecord].freeze
Instance Attribute Summary collapse
-
#approval_callback ⇒ Object
Returns the value of attribute approval_callback.
-
#code_only ⇒ Object
Returns the value of attribute code_only.
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#except_models ⇒ Object
readonly
Returns the value of attribute except_models.
-
#read_only ⇒ Object
Returns the value of attribute read_only.
-
#requested_models ⇒ Object
Returns the value of attribute requested_models.
Attributes inherited from EngineBoxcar
#engine, #prompt, #stop, #top_k
Attributes inherited from Boxcar
#description, #name, #parameters, #return_direct
Instance Method Summary collapse
-
#initialize(models: nil, except_models: nil, read_only: nil, approval_callback: nil, **kwargs) ⇒ ActiveRecord
constructor
A new instance of ActiveRecord.
-
#prediction_additional(_inputs) ⇒ Object
Hash The additional variables for this boxcar.
Methods inherited from EngineBoxcar
#apply, #call, #check_output_keys, #extract_code, #generate, #input_key, #input_keys, #output_key, #output_keys, #predict, #prediction_input, #prediction_variables
Methods inherited from Boxcar
#apply, assi, #call, #conduct, hist, #input_keys, #load, #output_keys, #run, #save, #schema, syst, user, #validate_inputs, #validate_outputs
Constructor Details
#initialize(models: nil, except_models: nil, read_only: nil, approval_callback: nil, **kwargs) ⇒ ActiveRecord
Returns a new instance of ActiveRecord.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/boxcars/boxcar/active_record.rb', line 20 def initialize(models: nil, except_models: nil, read_only: nil, approval_callback: nil, **kwargs) check_models(models, except_models) @approval_callback = approval_callback @read_only = read_only.nil? ? !approval_callback : read_only @code_only = kwargs.delete(:code_only) || false kwargs[:name] ||= get_name kwargs[:description] ||= format(ARDESC, name: name) kwargs[:prompt] ||= my_prompt super(**kwargs) end |
Instance Attribute Details
#approval_callback ⇒ Object
Returns the value of attribute approval_callback.
11 12 13 |
# File 'lib/boxcars/boxcar/active_record.rb', line 11 def approval_callback @approval_callback end |
#code_only ⇒ Object
Returns the value of attribute code_only.
11 12 13 |
# File 'lib/boxcars/boxcar/active_record.rb', line 11 def code_only @code_only end |
#connection ⇒ Object
Returns the value of attribute connection.
11 12 13 |
# File 'lib/boxcars/boxcar/active_record.rb', line 11 def connection @connection end |
#except_models ⇒ Object (readonly)
Returns the value of attribute except_models.
12 13 14 |
# File 'lib/boxcars/boxcar/active_record.rb', line 12 def except_models @except_models end |
#read_only ⇒ Object
Returns the value of attribute read_only.
11 12 13 |
# File 'lib/boxcars/boxcar/active_record.rb', line 11 def read_only @read_only end |
#requested_models ⇒ Object
Returns the value of attribute requested_models.
11 12 13 |
# File 'lib/boxcars/boxcar/active_record.rb', line 11 def requested_models @requested_models end |
Instance Method Details
#prediction_additional(_inputs) ⇒ Object
Returns Hash The additional variables for this boxcar.
32 33 34 |
# File 'lib/boxcars/boxcar/active_record.rb', line 32 def prediction_additional(_inputs) { model_info: model_info }.merge super end |