Class: NotionRubyMapping::UniqueIdProperty

Inherits:
Property
  • Object
show all
Includes:
EqualsDoesNotEqual, GreaterThanLessThan, IsEmptyIsNotEmpty
Defined in:
lib/notion_ruby_mapping/properties/unique_id_property.rb

Overview

Number property

Constant Summary collapse

TYPE =
"unique_id"

Instance Attribute Summary

Attributes inherited from Property

#name, #property_cache, #property_id, #will_update

Instance Method Summary collapse

Methods included from IsEmptyIsNotEmpty

#filter_is_empty, #filter_is_not_empty

Methods included from GreaterThanLessThan

#filter_greater_than, #filter_greater_than_or_equal_to, #filter_less_than, #filter_less_than_or_equal_to

Methods included from EqualsDoesNotEqual

#filter_does_not_equal, #filter_equals

Methods inherited from Property

#assert_data_source_property, #assert_database_or_data_source_property, #assert_database_property, #assert_page_property, #clear_will_update, #contents?, create_from_json, #data_source?, #database?, #database_or_data_source?, #make_filter_query, #new_name=, #page?, #property_schema_json, #remove, #retrieve_page_property, #type, #update_property_schema_json

Constructor Details

#initialize(name, will_update: false, base_type: "page", json: nil, property_id: nil, property_cache: nil) ⇒ UniqueIdProperty

Returns a new instance of UniqueIdProperty.

Parameters:

  • name (String)

    Property name

  • json (Float, Integer, Hash) (defaults to: nil)

    Number value or format Hash



30
31
32
33
34
# File 'lib/notion_ruby_mapping/properties/unique_id_property.rb', line 30

def initialize(name, will_update: false, base_type: "page", json: nil, property_id: nil, property_cache: nil)
  super name, will_update: will_update, base_type: base_type, property_id: property_id, property_cache: property_cache
  @json = json
  @json ||= {} if database_or_data_source?
end

Instance Method Details

#property_values_jsonHash

Returns:

  • (Hash)


49
50
51
52
# File 'lib/notion_ruby_mapping/properties/unique_id_property.rb', line 49

def property_values_json
  assert_page_property __method__
  {@name => {"unique_id" => @json, "type" => "unique_id"}}
end

#unique_idHash?

Returns:

  • (Hash, nil)


16
17
18
# File 'lib/notion_ruby_mapping/properties/unique_id_property.rb', line 16

def unique_id
  @json
end

#update_from_json(json) ⇒ NotionRubyMapping::NumberProperty

Parameters:

  • json (Hash)

Returns:



38
39
40
41
42
# File 'lib/notion_ruby_mapping/properties/unique_id_property.rb', line 38

def update_from_json(json)
  @will_update = false
  @json = json["unique_id"]
  self
end