Class: Notion::Objects::Block

Inherits:
Base
  • Object
show all
Defined in:
lib/notion/objects/types.rb

Constant Summary collapse

TYPES =
%w[
  audio bookmark breadcrumb bulleted_list_item callout child_database child_page code
  column column_list divider embed equation file heading_1 heading_2 heading_3 image
  link_preview link_to_page meeting_notes numbered_list_item paragraph pdf quote
  synced_block table table_of_contents table_row template todo toggle transcription video
].freeze

Instance Attribute Summary

Attributes inherited from Base

#raw

Class Method Summary collapse

Methods inherited from Base

#[], #deconstruct_keys, #in_trash?, #initialize, #inspect, #method_missing, #respond_to_missing?

Constructor Details

This class inherits a constructor from Notion::Objects::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Notion::Objects::Base

Class Method Details

.build(raw) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/notion/objects/types.rb', line 31

def self.build(raw)
  name = raw["type"].to_s.split("_").map(&:capitalize).join
  return new(raw) if name.empty?

  klass = const_defined?(name, false) ? const_get(name, false) : self
  klass.new(raw)
end