Class: NotionRubyMapping::UrlProperty

Inherits:
Property
  • Object
show all
Includes:
ContainsDoesNotContain, EqualsDoesNotEqual, IsEmptyIsNotEmpty, StartsWithEndsWith
Defined in:
lib/notion_ruby_mapping/properties/url_property.rb

Overview

UrlProperty

Constant Summary collapse

TYPE =
"url"

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 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, #clear_will_update, #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, property_id: nil, property_cache: nil) ⇒ UrlProperty

Returns a new instance of UrlProperty.

Parameters:

  • name (String, Symbol)

    Property name



37
38
39
40
41
# File 'lib/notion_ruby_mapping/properties/url_property.rb', line 37

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 || (database? ? {} : nil)
end

Instance Method Details

#property_values_jsonHash

Returns:

  • (Hash)


46
47
48
49
# File 'lib/notion_ruby_mapping/properties/url_property.rb', line 46

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

#urlString, ...

Returns url (Page), {} (Database).

Returns:

  • (String, Hash, nil)

    url (Page), {} (Database)

See Also:



18
19
20
# File 'lib/notion_ruby_mapping/properties/url_property.rb', line 18

def url
  @json
end

#url=(url) ⇒ Object



26
27
28
29
30
# File 'lib/notion_ruby_mapping/properties/url_property.rb', line 26

def url=(url)
  assert_page_property __method__
  @will_update = true
  @json = url
end