Class: NotionCf::DatabaseResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/notion_cf/database_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

#available_type?Boolean

Returns:

  • (Boolean)


26
27
28
29
30
# File 'lib/notion_cf/database_resource.rb', line 26

def available_type?
  return false if linked_database? # linked_databaseはNotion APIで作成できないので除外する

  super
end

#block?Boolean

Returns:

  • (Boolean)


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

def block?
  false
end

#deploy(client, parent_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/notion_cf/database_resource.rb', line 15

def deploy(client, parent_id)
  return if linked_database?

  unless @id.nil?
    update(client)
    return
  end

  create(client, parent_id)
end

#linked_database?Boolean

child_databaseのtitleが空の場合は、linked_databaseとして扱う

Returns:

  • (Boolean)


11
12
13
# File 'lib/notion_cf/database_resource.rb', line 11

def linked_database?
  @attributes[:title].empty?
end

#retrieve_additional_information(client, blueprints) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/notion_cf/database_resource.rb', line 32

def retrieve_additional_information(client, blueprints)
  return if linked_database?

  database_detail = client.database(database_id: @id)
  parent = blueprints.detect { |h| h[:id] == @id }
  parent[:child_database].merge!(database_detail)
end