Class: NotionRubyMapping::UniqueIdProperty

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

Overview

Unique ID 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_page_property, #clear_will_update, create_from_json, #data_source?, #database?, #database_or_data_source?, #make_filter_query, #new_name=, #page?, #property_schema_json, #remove, #retrieve_page_property, #type

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 (Hash, nil) (defaults to: nil)

    unique_id Hash



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

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

#numberInteger?

Returns:

  • (Integer, nil)


26
27
28
# File 'lib/notion_ruby_mapping/properties/unique_id_property.rb', line 26

def number
  @json && @json["number"]
end

#prefixString?

Returns:

  • (String, nil)


21
22
23
# File 'lib/notion_ruby_mapping/properties/unique_id_property.rb', line 21

def prefix
  @json && @json["prefix"]
end

#prefix=(prefix) ⇒ String?

Parameters:

  • prefix (String, nil)

Returns:

  • (String, nil)


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

def prefix=(prefix)
  assert_database_or_data_source_property __method__
  @will_update = true
  @json["prefix"] = prefix
end

#property_values_jsonHash

Returns:

  • (Hash)


78
79
80
81
# File 'lib/notion_ruby_mapping/properties/unique_id_property.rb', line 78

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::UniqueIdProperty

Parameters:

  • json (Hash)

Returns:



56
57
58
59
60
# File 'lib/notion_ruby_mapping/properties/unique_id_property.rb', line 56

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

#update_property_schema_jsonHash

Returns:

  • (Hash)


65
66
67
68
69
70
71
72
73
# File 'lib/notion_ruby_mapping/properties/unique_id_property.rb', line 65

def update_property_schema_json
  assert_database_or_data_source_property __method__
  ans = super
  return ans if ans != {} || !@will_update

  ans[@name] ||= {}
  ans[@name]["unique_id"] = @json
  ans
end