Class: NotionCf::BlockResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/notion_cf/block_resource.rb

Overview

BlockResource class

Constant Summary

Constants inherited from Resource

Resource::AVAILABLE_TYPES

Instance Attribute Summary

Attributes inherited from Resource

#attributes, #has_children, #id, #object, #parent, #type

Instance Method Summary collapse

Methods inherited from Resource

#blueprint, build_resource, #initialize

Constructor Details

This class inherits a constructor from NotionCf::Resource

Instance Method Details

#block?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/notion_cf/block_resource.rb', line 6

def block?
  true
end

#deploy(client, parent_id = nil) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/notion_cf/block_resource.rb', line 10

def deploy(client, parent_id = nil)
  unless @id.nil?
    update(client)
    return
  end

  create(client, parent_id)
end

#retrieve_additional_information(client, blueprints) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/notion_cf/block_resource.rb', line 19

def retrieve_additional_information(client, blueprints)
  return unless @has_children

  children = client.retrieve_children(@id)
  parent = blueprints.detect { |h| h[:id] == @id }
  block_type = @type.to_sym
  parent[block_type][:children] = children
  children.filter_map do |child|
    next unless (resource = NotionCf::Resource.build_resource(child)).has_children

    resource.retrieve_additional_information(client, parent[block_type][:children])
  end
end