Class: NotionCf::Resource
- Inherits:
-
Object
- Object
- NotionCf::Resource
- Defined in:
- lib/notion_cf/resource.rb
Overview
Notionのブロック、ページ、データベースを表す抽象クラス ストラテジーパターン
Direct Known Subclasses
Constant Summary collapse
- AVAILABLE_TYPES =
unsupportedはNotion APIで作成できないので、テンプレートファイルには含めない
%w[paragraph to_do heading_1 heading_2 heading_3 bulleted_list_item numbered_list_item toggle quote divider link_to_page callout image bookmark video audio code file table_of_contents equation breadcrumb synced_block column_list table child_database child_page].freeze
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#has_children ⇒ Object
readonly
Returns the value of attribute has_children.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.build_resource(blueprint) ⇒ Object
ファクトリーメソッド.
Instance Method Summary collapse
- #block? ⇒ Boolean
- #blueprint ⇒ Object
- #deploy(_client, _parent_id = nil) ⇒ Object
-
#initialize(blueprint) ⇒ Resource
constructor
A new instance of Resource.
- #retrieve_additional_information(_client, _blueprints) ⇒ Object
Constructor Details
#initialize(blueprint) ⇒ Resource
Returns a new instance of Resource.
31 32 33 34 35 36 37 38 39 |
# File 'lib/notion_cf/resource.rb', line 31 def initialize(blueprint) @blueprint = blueprint @object = blueprint[:object] @id = blueprint[:id] @type = blueprint[:type] @parent = blueprint[:parent] @has_children = blueprint[:has_children] @attributes = blueprint[@type.to_sym] end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
13 14 15 |
# File 'lib/notion_cf/resource.rb', line 13 def attributes @attributes end |
#has_children ⇒ Object (readonly)
Returns the value of attribute has_children.
13 14 15 |
# File 'lib/notion_cf/resource.rb', line 13 def has_children @has_children end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
13 14 15 |
# File 'lib/notion_cf/resource.rb', line 13 def id @id end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
13 14 15 |
# File 'lib/notion_cf/resource.rb', line 13 def object @object end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
13 14 15 |
# File 'lib/notion_cf/resource.rb', line 13 def parent @parent end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
13 14 15 |
# File 'lib/notion_cf/resource.rb', line 13 def type @type end |
Class Method Details
.build_resource(blueprint) ⇒ Object
ファクトリーメソッド
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/notion_cf/resource.rb', line 17 def build_resource(blueprint) return unless blueprint case blueprint[:type] when 'child_database' NotionCf::DatabaseResource.new(blueprint) when 'child_page' NotionCf::PageResource.new(blueprint) else NotionCf::BlockResource.new(blueprint) end end |
Instance Method Details
#block? ⇒ Boolean
41 42 43 |
# File 'lib/notion_cf/resource.rb', line 41 def block? raise NotImplementedError end |
#blueprint ⇒ Object
49 50 51 |
# File 'lib/notion_cf/resource.rb', line 49 def blueprint @blueprint if available_type? end |
#deploy(_client, _parent_id = nil) ⇒ Object
45 46 47 |
# File 'lib/notion_cf/resource.rb', line 45 def deploy(_client, _parent_id = nil) raise NotImplementedError end |
#retrieve_additional_information(_client, _blueprints) ⇒ Object
53 54 55 |
# File 'lib/notion_cf/resource.rb', line 53 def retrieve_additional_information(_client, _blueprints) raise NotImplementedError end |