Class: NotionRubyMapping::CreatedByProperty

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

Overview

CreatedByProperty

Constant Summary collapse

TYPE =
"created_by"

Instance Attribute Summary

Attributes inherited from Property

#name, #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, create_from_json, #database?, #make_filter_query, #new_name=, #page?, #property_schema_json, #property_values_json, #remove, #type, #update_property_schema_json

Constructor Details

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

Returns a new instance of CreatedByProperty.

Parameters:

  • name (String)

    Property name

  • user_id (String) (defaults to: nil)

    user_id (optional)

  • json (Hash) (defaults to: nil)

    json (optional)



24
25
26
27
28
29
30
31
# File 'lib/notion_ruby_mapping/created_by_property.rb', line 24

def initialize(name, will_update: false, base_type: :page, json: nil, user_id: nil)
  super name, will_update: will_update, base_type: base_type
  @json = if database?
            json || {}
          else
            UserObject.new user_id: user_id, json: json
          end
end

Instance Method Details

#created_byNotionRubyMapping::UserObject, Hash



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

def created_by
  @json
end

#update_from_json(json) ⇒ Object

Parameters:

  • json (Hash)


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

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