Class: Ecoportal::API::GraphQL::Builder::Template
- Inherits:
-
Object
- Object
- Ecoportal::API::GraphQL::Builder::Template
- Defined in:
- lib/ecoportal/api/graphql/builder/template.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#change_log(detail: false, **kargs, &block) ⇒ Object
TEMPLATE CHANGE LOG — who changed this template, what, and when.
- #create(commands:, register_id: nil, &block) ⇒ Object
- #create_related_page(template_id:, title:, register_id:, patch_ver:, filters: nil, &block) ⇒ Object
- #destroy_related_page(template_id:, id:, patch_ver:, &block) ⇒ Object
-
#initialize(client) ⇒ Template
constructor
A new instance of Template.
- #publish(id:, &block) ⇒ Object
- #unpublish(id:, &block) ⇒ Object
- #update(model, commands:, patch_ver: model.patchVer, client_mutation_id: nil, &block) ⇒ Object
- #update_information(id:, **kargs, &block) ⇒ Object
-
#update_related_page(template_id:, id:, patch_ver:, title: nil, register_id: nil, filters: nil, &block) ⇒ Object
Edits an existing related-pages entry.
Constructor Details
#initialize(client) ⇒ Template
Returns a new instance of Template.
8 9 10 |
# File 'lib/ecoportal/api/graphql/builder/template.rb', line 8 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/ecoportal/api/graphql/builder/template.rb', line 6 def client @client end |
Instance Method Details
#change_log(detail: false, **kargs, &block) ⇒ Object
TEMPLATE CHANGE LOG — who changed this template, what, and when. Newest first
(server-side _id: :desc), paginated.
api.template.change_log(id: template_page_id, first: 50) # => Connection
api.template.change_log.each(id: template_page_id) { |e| ... } # auto-paginates
★ Two caveats, both silent — read Base::Template::ChangeLogEntry before relying on
this: the connection is nil (not empty) unless the caller satisfies
Pages::TemplatePolicy#update_information?, and only TEMPLATE_BUILDER-sourced
commands appear (workflow-builder ones are on Query::PagesWorkflowCommands).
Called with no arguments it returns the query object itself, so #each /#map and
the rest of Enumerable are available — same idiom as the QueryIntegration queries on
Model::Organization.
83 84 85 86 87 88 |
# File 'lib/ecoportal/api/graphql/builder/template.rb', line 83 def change_log(detail: false, **kargs, &block) selection = block || (detail ? Query::TemplateChangeLog.detail_block : nil) return changeLogQuery if kargs.empty? && !selection changeLogQuery.query(**kargs, &selection) end |
#create(commands:, register_id: nil, &block) ⇒ Object
15 16 17 |
# File 'lib/ecoportal/api/graphql/builder/template.rb', line 15 def create(commands:, register_id: nil, &block) createMutation.query(commands: commands, register_id: register_id, &block) end |
#create_related_page(template_id:, title:, register_id:, patch_ver:, filters: nil, &block) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ecoportal/api/graphql/builder/template.rb', line 37 def (template_id:, title:, register_id:, patch_ver:, filters: nil, &block) .query( template_id: template_id, title: title, register_id: register_id, patch_ver: patch_ver, filters: filters, &block ) end |
#destroy_related_page(template_id:, id:, patch_ver:, &block) ⇒ Object
62 63 64 |
# File 'lib/ecoportal/api/graphql/builder/template.rb', line 62 def (template_id:, id:, patch_ver:, &block) .query(template_id: template_id, id: id, patch_ver: patch_ver, &block) end |
#publish(id:, &block) ⇒ Object
25 26 27 |
# File 'lib/ecoportal/api/graphql/builder/template.rb', line 25 def publish(id:, &block) publishMutation.query(id: id, &block) end |
#unpublish(id:, &block) ⇒ Object
29 30 31 |
# File 'lib/ecoportal/api/graphql/builder/template.rb', line 29 def unpublish(id:, &block) unpublishMutation.query(id: id, &block) end |
#update(model, commands:, patch_ver: model.patchVer, client_mutation_id: nil, &block) ⇒ Object
19 20 21 22 23 |
# File 'lib/ecoportal/api/graphql/builder/template.rb', line 19 def update(model, commands:, patch_ver: model.patchVer, client_mutation_id: nil, &block) kwargs = { id: model.id, patch_ver: patch_ver, commands: commands } kwargs[:client_mutation_id] = client_mutation_id unless client_mutation_id.nil? updateMutation.query(**kwargs, &block) end |
#update_information(id:, **kargs, &block) ⇒ Object
33 34 35 |
# File 'lib/ecoportal/api/graphql/builder/template.rb', line 33 def update_information(id:, **kargs, &block) updateInformationMutation.query(id: id, **kargs, &block) end |
#update_related_page(template_id:, id:, patch_ver:, title: nil, register_id: nil, filters: nil, &block) ⇒ Object
Edits an existing related-pages entry. Only the keys you pass are sent — absent keys are left alone server-side, so this is a partial update, not a replace.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ecoportal/api/graphql/builder/template.rb', line 50 def (template_id:, id:, patch_ver:, title: nil, register_id: nil, filters: nil, &block) .query( template_id: template_id, id: id, patch_ver: patch_ver, title: title, register_id: register_id, filters: filters, &block ) end |