Class: NotionRubyMapping::UserObject
- Inherits:
-
Object
- Object
- NotionRubyMapping::UserObject
- Defined in:
- lib/notion_ruby_mapping/objects/user_object.rb
Overview
TextObject
Instance Attribute Summary collapse
-
#json ⇒ Object
readonly
Returns the value of attribute json.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
-
#will_update ⇒ Object
readonly
Returns the value of attribute will_update.
Class Method Summary collapse
- .all(dry_run: false) ⇒ Object
- .find(user_id, dry_run: false) ⇒ NotionRubyMapping::UserObject, String
- .find_me(dry_run: false) ⇒ Object
-
.user_object(user_id_or_uo) ⇒ UserObject
Self or created UserObject.
Instance Method Summary collapse
- #initialize(user_id: nil, json: {}) ⇒ TextObject constructor
- #inspect ⇒ String (frozen)
- #name ⇒ String
- #property_values_json ⇒ Hash
Constructor Details
#initialize(user_id: nil, json: {}) ⇒ TextObject
8 9 10 11 12 |
# File 'lib/notion_ruby_mapping/objects/user_object.rb', line 8 def initialize(user_id: nil, json: {}) @user_id = NotionCache.instance.hex_id(user_id || json && json["id"]) @json = json @will_update = false end |
Instance Attribute Details
#json ⇒ Object (readonly)
Returns the value of attribute json.
13 14 15 |
# File 'lib/notion_ruby_mapping/objects/user_object.rb', line 13 def json @json end |
#user_id ⇒ Object
Returns the value of attribute user_id.
13 14 15 |
# File 'lib/notion_ruby_mapping/objects/user_object.rb', line 13 def user_id @user_id end |
#will_update ⇒ Object (readonly)
Returns the value of attribute will_update.
13 14 15 |
# File 'lib/notion_ruby_mapping/objects/user_object.rb', line 13 def will_update @will_update end |
Class Method Details
.all(dry_run: false) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/notion_ruby_mapping/objects/user_object.rb', line 16 def self.all(dry_run: false) nc = NotionCache.instance if dry_run Base.dry_run_script :get, nc.users_path else nc.users end end |
.find(user_id, dry_run: false) ⇒ NotionRubyMapping::UserObject, String
28 29 30 31 32 33 34 35 |
# File 'lib/notion_ruby_mapping/objects/user_object.rb', line 28 def self.find(user_id, dry_run: false) nc = NotionCache.instance if dry_run Base.dry_run_script :get, nc.user_path(user_id) else nc.user user_id end end |
.find_me(dry_run: false) ⇒ Object
38 39 40 |
# File 'lib/notion_ruby_mapping/objects/user_object.rb', line 38 def self.find_me(dry_run: false) find "me", dry_run: dry_run end |
.user_object(user_id_or_uo) ⇒ UserObject
Returns self or created UserObject.
44 45 46 47 48 49 50 |
# File 'lib/notion_ruby_mapping/objects/user_object.rb', line 44 def self.user_object(user_id_or_uo) if user_id_or_uo.is_a? UserObject user_id_or_uo else UserObject.new user_id: user_id_or_uo end end |
Instance Method Details
#inspect ⇒ String (frozen)
53 54 55 |
# File 'lib/notion_ruby_mapping/objects/user_object.rb', line 53 def inspect "#{self.class.name}-#{@user_id}" end |
#name ⇒ String
58 59 60 |
# File 'lib/notion_ruby_mapping/objects/user_object.rb', line 58 def name @json["name"] end |
#property_values_json ⇒ Hash
63 64 65 66 67 68 |
# File 'lib/notion_ruby_mapping/objects/user_object.rb', line 63 def property_values_json { "object" => "user", "id" => @user_id, } end |