Class: NotionRubyMapping::CreatedByProperty

Inherits:
MultiProperty show all
Defined in:
lib/notion_ruby_mapping/properties/created_by_property.rb

Overview

CreatedByProperty

Constant Summary collapse

TYPE =
"created_by"

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 ContainsDoesNotContain

#filter_contains, #filter_does_not_contain

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_property_schema_json

Constructor Details

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

Returns a new instance of CreatedByProperty.

Parameters:

  • name (String, Symbol)

    Property name

  • user_id (String) (defaults to: nil)

    user_id (optional)

  • json (Hash) (defaults to: nil)

    json (optional)



25
26
27
28
29
30
31
32
33
34
# File 'lib/notion_ruby_mapping/properties/created_by_property.rb', line 25

def initialize(name, will_update: false, base_type: "page", json: nil, user_id: 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 = if database?
            json || {}
          else
            UserObject.new user_id: user_id, json: json
          end
end

Instance Method Details

#created_byNotionRubyMapping::UserObject, Hash



14
15
16
# File 'lib/notion_ruby_mapping/properties/created_by_property.rb', line 14

def created_by
  @json
end

#property_values_jsonHash

Page property only methods

Returns:

  • (Hash)


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

def property_values_json
  assert_page_property __method__
  {}
end

#update_from_json(json) ⇒ Object

Parameters:

  • json (Hash)


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

def update_from_json(json)
  @will_update = false
  cb = json["created_by"]
  @json = database? ? cb : UserObject.new(json: cb)
end