Class: Clerq::Services::CreateNode

Inherits:
Service
  • Object
show all
Defined in:
lib/clerq/services/create_node.rb

Overview

Creates new node in repository according to provided parameters or raises CreateNode::Failure when

* template not found
* or repository contains a node with the same id

Instance Method Summary collapse

Methods inherited from Service

call

Instance Method Details

#callObject



16
17
18
19
20
21
# File 'lib/clerq/services/create_node.rb', line 16

def call
  @body = QueryTemplate.(@template) if @body.empty? && !@template.empty?
  @node = Clerq::Entities::Node.new(
    id: @id, title: @title, body: @body, meta: @meta)
  Clerq.node_repository.save(@node)
end