Class: NotionRubyMapping::TitleProperty

Inherits:
TextProperty show all
Defined in:
lib/notion_ruby_mapping/properties/title_property.rb

Overview

TitleProperty

Constant Summary collapse

TYPE =
"title"

Instance Attribute Summary

Attributes inherited from TextProperty

#text_objects

Attributes inherited from Property

#name, #property_cache, #property_id, #will_update

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TextProperty

#initialize, #will_update

Methods included from IsEmptyIsNotEmpty

#filter_is_empty, #filter_is_not_empty

Methods included from StartsWithEndsWith

#filter_ends_with, #filter_starts_with

Methods included from ContainsDoesNotContain

#filter_contains, #filter_does_not_contain

Methods included from EqualsDoesNotEqual

#filter_does_not_equal, #filter_equals

Methods inherited from Property

#assert_database_property, #assert_page_property, #contents?, create_from_json, #database?, #initialize, #make_filter_query, #new_name=, #page?, #property_schema_json, #remove, #retrieve_page_property, #type, #update_property_schema_json

Constructor Details

This class inherits a constructor from NotionRubyMapping::TextProperty

Class Method Details

.rich_text_array_from_json(json) ⇒ Object

Common methods


12
13
14
15
16
17
18
19
# File 'lib/notion_ruby_mapping/properties/title_property.rb', line 12

def self.rich_text_array_from_json(json)
  if json["object"] == "list"
    rich_text_objects = List.new(json: json, type: :property, value: self).select { true }
    RichTextArray.rich_text_array "title", rich_text_objects
  else
    RichTextArray.new "title", json: json["title"]
  end
end

Instance Method Details

#clear_will_updateFalseClass

Returns:

  • (FalseClass)

34
35
36
37
38
# File 'lib/notion_ruby_mapping/properties/title_property.rb', line 34

def clear_will_update
  super
  @text_objects.clear_will_update
  false
end

#property_values_jsonHash

Returns created json.

Returns:

  • (Hash)

    created json


41
42
43
44
45
46
47
48
49
50
# File 'lib/notion_ruby_mapping/properties/title_property.rb', line 41

def property_values_json
  assert_page_property __method__
  text_json = map(&:property_values_json)
  {
    @name => {
      "type" => "title",
      "title" => text_json.empty? ? @json : text_json,
    },
  }
end

#update_from_json(json) ⇒ Object

Parameters:

  • json (Hash)

22
23
24
25
26
27
28
29
# File 'lib/notion_ruby_mapping/properties/title_property.rb', line 22

def update_from_json(json)
  @will_update = false
  if database?
    @json = json || {}
  else
    @text_objects = TitleProperty.rich_text_array_from_json json
  end
end