Class: NotionRubyMapping::TextProperty

Inherits:
Property
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable, ContainsDoesNotContain, EqualsDoesNotEqual, IsEmptyIsNotEmpty, StartsWithEndsWith
Defined in:
lib/notion_ruby_mapping/properties/text_property.rb

Overview

Text property

Direct Known Subclasses

RichTextProperty, TitleProperty

Instance Attribute Summary collapse

Attributes inherited from Property

#name, #property_cache, #property_id

Instance Method Summary collapse

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?, #make_filter_query, #new_name=, #page?, #property_schema_json, #remove, #retrieve_page_property, #type, #update_from_json, #update_property_schema_json

Constructor Details

#initialize(name, will_update: false, base_type: :page, json: nil, text_objects: nil, property_id: nil, property_cache: nil, query: nil) ⇒ TextProperty

Returns a new instance of TextProperty.

Parameters:

  • name (String)
  • json (Hash, Array) (defaults to: nil)
  • text_objects (Array<RichTextObject>) (defaults to: nil)

Raises:

  • (StandardError)

30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/notion_ruby_mapping/properties/text_property.rb', line 30

def initialize(name, will_update: false, base_type: :page, json: nil, text_objects: nil, property_id: nil,
               property_cache: nil, query: nil)
  raise StandardError, "TextObject is abstract class.  Please use RichTextProperty." if instance_of? TextProperty

  super name, will_update: will_update, base_type: base_type, property_id: property_id,
              property_cache: property_cache, query: query
  @text_objects = if database?
                    json || {}
                  else
                    RichTextArray.new "title", json: json, text_objects: text_objects
                  end
end

Instance Attribute Details

#text_objectsObject (readonly)

Page property only methods


19
20
21
# File 'lib/notion_ruby_mapping/properties/text_property.rb', line 19

def text_objects
  @text_objects
end

Instance Method Details

#clear_will_updateFalseClass

Returns:

  • (FalseClass)

44
45
46
47
48
# File 'lib/notion_ruby_mapping/properties/text_property.rb', line 44

def clear_will_update
  super
  @text_objects.clear_will_update if page?
  false
end

#will_updateTrueClass, FalseClass

Returns will update?.

Returns:

  • (TrueClass, FalseClass)

    will update?


51
52
53
# File 'lib/notion_ruby_mapping/properties/text_property.rb', line 51

def will_update
  @will_update || (page? && @text_objects.will_update)
end