Class: Tama::Memory::Service
- Inherits:
-
Object
- Object
- Tama::Memory::Service
- Defined in:
- lib/tama/memory/service.rb
Instance Method Summary collapse
- #create_entity(klass, attributes = nil, headers: {}, timeout: nil, **attribute_keywords) ⇒ Object
-
#initialize(http) ⇒ Service
constructor
A new instance of Service.
Constructor Details
#initialize(http) ⇒ Service
Returns a new instance of Service.
6 7 8 |
# File 'lib/tama/memory/service.rb', line 6 def initialize(http) @http = http end |
Instance Method Details
#create_entity(klass, attributes = nil, headers: {}, timeout: nil, **attribute_keywords) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/tama/memory/service.rb', line 10 def create_entity(klass, attributes = nil, headers: {}, timeout: nil, **attribute_keywords) @http.validate_namespace!("ingest") class_id = klass.is_a?(Neural::Klass) ? klass.id : klass attributes ||= attribute_keywords params = attributes.is_a?(EntityParams) ? attributes : EntityParams.parse(attributes) path = "memory/classes/#{HTTP.segment(class_id, "class_id")}/entities" response = @http.request(:post, path, body: {"entity" => params.to_h}, headers:, timeout:) @http.parse_data(response, Entity) end |