Class: RosettAi::Provenance::Source
- Inherits:
-
Object
- Object
- RosettAi::Provenance::Source
- Defined in:
- lib/rosett_ai/provenance/source.rb
Overview
Classifies the source type of an AI contribution.
Source types track where AI-generated code drew its knowledge from, enabling license traceability and compliance auditing.
Constant Summary collapse
- ALLOWED_TYPES =
[ 'library_api', 'project_code', 'documentation', 'pattern', 'external_source' ].freeze
Instance Attribute Summary collapse
-
#reference ⇒ Object
readonly
Returns the value of attribute reference.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(type:, reference:, url: nil) ⇒ Source
constructor
A new instance of Source.
-
#to_h ⇒ Hash
Serializable representation.
Constructor Details
#initialize(type:, reference:, url: nil) ⇒ Source
Returns a new instance of Source.
28 29 30 31 32 33 34 35 |
# File 'lib/rosett_ai/provenance/source.rb', line 28 def initialize(type:, reference:, url: nil) validate_type!(type) validate_url!(type, url) @type = type.freeze @reference = reference.freeze @url = url&.freeze end |
Instance Attribute Details
#reference ⇒ Object (readonly)
Returns the value of attribute reference.
21 22 23 |
# File 'lib/rosett_ai/provenance/source.rb', line 21 def reference @reference end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
21 22 23 |
# File 'lib/rosett_ai/provenance/source.rb', line 21 def type @type end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
21 22 23 |
# File 'lib/rosett_ai/provenance/source.rb', line 21 def url @url end |
Instance Method Details
#to_h ⇒ Hash
Returns serializable representation.
38 39 40 41 42 |
# File 'lib/rosett_ai/provenance/source.rb', line 38 def to_h hash = { 'type' => @type, 'reference' => @reference } hash['url'] = @url if @url hash end |