Class: NotionCf::Resources
- Inherits:
-
Object
- Object
- NotionCf::Resources
- Defined in:
- lib/notion_cf/resources.rb
Overview
block, page, databaseなどリソースの集合 FirstClassCollectionパターン(?)
Instance Method Summary collapse
- #blueprints ⇒ Object
- #deploy(blueprints) ⇒ Object
-
#initialize(page_id:) ⇒ Resources
constructor
A new instance of Resources.
- #retrieve ⇒ Object
Constructor Details
#initialize(page_id:) ⇒ Resources
Returns a new instance of Resources.
7 8 9 10 11 |
# File 'lib/notion_cf/resources.rb', line 7 def initialize(page_id:) @client = NotionCf::NotionApiClient.new @page_id = page_id @resources = [] end |
Instance Method Details
#blueprints ⇒ Object
30 31 32 |
# File 'lib/notion_cf/resources.rb', line 30 def blueprints @resources.map(&:blueprint) end |
#deploy(blueprints) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/notion_cf/resources.rb', line 13 def deploy(blueprints) blueprints.each do |blueprint| resource = NotionCf::Resource.build_resource(blueprint) next if resource.nil? resource.deploy(@client, @page_id) end end |
#retrieve ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/notion_cf/resources.rb', line 22 def retrieve blueprints = @client.block_children(block_id: @page_id) blueprints.each do |blueprint| resource = NotionCf::Resource.build_resource(blueprint) @resources << resource end end |