Class: NotionRubyMapping::LastEditedByProperty

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

Overview

LastEditedByProperty

Constant Summary collapse

TYPE =
"last_edited_by"

Instance Attribute Summary collapse

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) ⇒ LastEditedByProperty

Returns a new instance of LastEditedByProperty.

Parameters:

  • name (String)

    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
35
# File 'lib/notion_ruby_mapping/properties/last_edited_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 Attribute Details

#userObject (readonly)

Returns the value of attribute user.



36
37
38
# File 'lib/notion_ruby_mapping/properties/last_edited_by_property.rb', line 36

def user
  @user
end

Instance Method Details

#last_edited_byNotionRubyMapping::UserObject, Hash



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

def last_edited_by
  @json
end

#property_values_jsonHash

Page property only methods

Returns:

  • (Hash)


47
48
49
50
# File 'lib/notion_ruby_mapping/properties/last_edited_by_property.rb', line 47

def property_values_json
  assert_page_property __method__
  {}
end

#update_from_json(json) ⇒ Object

Parameters:

  • json (Hash)


39
40
41
42
43
# File 'lib/notion_ruby_mapping/properties/last_edited_by_property.rb', line 39

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