Class: NotionRubyMapping::Page
- Defined in:
- lib/notion_ruby_mapping/blocks/page.rb
Overview
Notion page object
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #build_child_database(title, *assigns) {|db, db.properties| ... } ⇒ NotionRubyMapping::Database
- #create_child_database(title, *assigns, dry_run: false) {|db, db.properties| ... } ⇒ Object
-
#title ⇒ String
Title.
Methods inherited from Base
#[], #append_block_children, #assert_parent_children_pair, #assign_property, #block?, #children, #create_child_breadcrumb, create_from_json, #created_time, #database?, #description, dry_run_script, #icon, #initialize, #json_properties, #last_edited_time, #new_record?, #page?, #properties, #property_values_json, #reload, #restore_from_json, #save, #set_icon, #update_json
Constructor Details
This class inherits a constructor from NotionRubyMapping::Base
Class Method Details
.find(id, dry_run: false) ⇒ NotionRubyMapping::Page, String
11 12 13 14 15 16 17 18 |
# File 'lib/notion_ruby_mapping/blocks/page.rb', line 11 def self.find(id, dry_run: false) nc = NotionCache.instance if dry_run Base.dry_run_script :get, nc.page_path(id) else nc.page id end end |
Instance Method Details
#build_child_database(title, *assigns) {|db, db.properties| ... } ⇒ NotionRubyMapping::Database
24 25 26 27 28 29 |
# File 'lib/notion_ruby_mapping/blocks/page.rb', line 24 def build_child_database(title, *assigns) db = Database.new json: {"title" => [TextObject.new(title).property_values_json]}, assign: assigns, parent: {"type" => "page_id", "page_id" => @id} yield db, db.properties if block_given? db end |
#create_child_database(title, *assigns, dry_run: false) {|db, db.properties| ... } ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/notion_ruby_mapping/blocks/page.rb', line 31 def create_child_database(title, *assigns, dry_run: false) build_child_database title, *assigns db = Database.new json: {"title" => [TextObject.new(title).property_values_json]}, assign: assigns, parent: {"type" => "page_id", "page_id" => @id} yield db, db.properties db.save dry_run: dry_run end |
#title ⇒ String
Returns title.
41 42 43 |
# File 'lib/notion_ruby_mapping/blocks/page.rb', line 41 def title properties.select { |p| p.is_a? TitleProperty }.map(&:full_text).join "" end |