Class: NotionCf::DatabaseResource
- Defined in:
- lib/notion_cf/database_resource.rb
Overview
BlockResource class
Constant Summary
Constants inherited from Resource
Instance Attribute Summary
Attributes inherited from Resource
#attributes, #has_children, #id, #object, #parent, #type
Instance Method Summary collapse
- #available_type? ⇒ Boolean
- #block? ⇒ Boolean
- #deploy(client, parent_id) ⇒ Object
-
#linked_database? ⇒ Boolean
child_databaseのtitleが空の場合は、linked_databaseとして扱う.
- #retrieve_additional_information(client, blueprints) ⇒ Object
Methods inherited from Resource
#blueprint, build_resource, #initialize
Constructor Details
This class inherits a constructor from NotionCf::Resource
Instance Method Details
#available_type? ⇒ 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
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として扱う
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 |