notion_ruby_mapping 0.8.8 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +12 -1
  3. data/README.md +1 -0
  4. data/lib/notion_ruby_mapping/blocks/base.rb +33 -33
  5. data/lib/notion_ruby_mapping/blocks/block.rb +48 -47
  6. data/lib/notion_ruby_mapping/blocks/bookmark_block.rb +1 -1
  7. data/lib/notion_ruby_mapping/blocks/breadcrumb_block.rb +1 -1
  8. data/lib/notion_ruby_mapping/blocks/bulleted_list_item_block.rb +1 -1
  9. data/lib/notion_ruby_mapping/blocks/callout_block.rb +10 -10
  10. data/lib/notion_ruby_mapping/blocks/child_base_block.rb +2 -2
  11. data/lib/notion_ruby_mapping/blocks/child_database_block.rb +3 -3
  12. data/lib/notion_ruby_mapping/blocks/child_page_block.rb +3 -3
  13. data/lib/notion_ruby_mapping/blocks/code_block.rb +7 -7
  14. data/lib/notion_ruby_mapping/blocks/column_block.rb +3 -3
  15. data/lib/notion_ruby_mapping/blocks/column_list_block.rb +2 -2
  16. data/lib/notion_ruby_mapping/blocks/database.rb +6 -6
  17. data/lib/notion_ruby_mapping/blocks/divider_block.rb +1 -1
  18. data/lib/notion_ruby_mapping/blocks/embed_block.rb +2 -2
  19. data/lib/notion_ruby_mapping/blocks/equation_block.rb +5 -5
  20. data/lib/notion_ruby_mapping/blocks/file_base_block.rb +2 -2
  21. data/lib/notion_ruby_mapping/blocks/file_block.rb +1 -1
  22. data/lib/notion_ruby_mapping/blocks/heading1_block.rb +4 -4
  23. data/lib/notion_ruby_mapping/blocks/heading2_block.rb +2 -2
  24. data/lib/notion_ruby_mapping/blocks/heading3_block.rb +3 -3
  25. data/lib/notion_ruby_mapping/blocks/image_block.rb +1 -1
  26. data/lib/notion_ruby_mapping/blocks/link_preview_block.rb +2 -2
  27. data/lib/notion_ruby_mapping/blocks/link_to_page_block.rb +5 -5
  28. data/lib/notion_ruby_mapping/blocks/list.rb +21 -20
  29. data/lib/notion_ruby_mapping/blocks/numbered_list_item_block.rb +2 -2
  30. data/lib/notion_ruby_mapping/blocks/page.rb +9 -10
  31. data/lib/notion_ruby_mapping/blocks/paragraph_block.rb +2 -2
  32. data/lib/notion_ruby_mapping/blocks/pdf_block.rb +2 -2
  33. data/lib/notion_ruby_mapping/blocks/quote_block.rb +1 -1
  34. data/lib/notion_ruby_mapping/blocks/synced_block.rb +5 -5
  35. data/lib/notion_ruby_mapping/blocks/table_block.rb +8 -8
  36. data/lib/notion_ruby_mapping/blocks/table_of_contents_block.rb +3 -3
  37. data/lib/notion_ruby_mapping/blocks/table_row_block.rb +3 -3
  38. data/lib/notion_ruby_mapping/blocks/template_block.rb +3 -3
  39. data/lib/notion_ruby_mapping/blocks/text_sub_block_color_base_block.rb +4 -4
  40. data/lib/notion_ruby_mapping/blocks/to_do_block.rb +4 -4
  41. data/lib/notion_ruby_mapping/blocks/toggle_block.rb +2 -2
  42. data/lib/notion_ruby_mapping/blocks/toggle_heading1_block.rb +2 -2
  43. data/lib/notion_ruby_mapping/blocks/toggle_heading2_block.rb +2 -2
  44. data/lib/notion_ruby_mapping/blocks/toggle_heading3_block.rb +3 -3
  45. data/lib/notion_ruby_mapping/blocks/url_base_block.rb +3 -3
  46. data/lib/notion_ruby_mapping/blocks/url_caption_base_block.rb +4 -4
  47. data/lib/notion_ruby_mapping/blocks/video_block.rb +2 -2
  48. data/lib/notion_ruby_mapping/controllers/discussion_thread.rb +1 -1
  49. data/lib/notion_ruby_mapping/controllers/mermaid_database.rb +34 -34
  50. data/lib/notion_ruby_mapping/controllers/notion_cache.rb +6 -8
  51. data/lib/notion_ruby_mapping/controllers/payload.rb +11 -11
  52. data/lib/notion_ruby_mapping/controllers/property_cache.rb +8 -7
  53. data/lib/notion_ruby_mapping/controllers/query.rb +10 -10
  54. data/lib/notion_ruby_mapping/controllers/search.rb +5 -6
  55. data/lib/notion_ruby_mapping/objects/comment_object.rb +2 -2
  56. data/lib/notion_ruby_mapping/objects/emoji_object.rb +3 -3
  57. data/lib/notion_ruby_mapping/objects/equation_object.rb +3 -3
  58. data/lib/notion_ruby_mapping/objects/file_object.rb +9 -9
  59. data/lib/notion_ruby_mapping/objects/mention_object.rb +43 -43
  60. data/lib/notion_ruby_mapping/objects/rich_text_object.rb +43 -43
  61. data/lib/notion_ruby_mapping/objects/text_object.rb +5 -5
  62. data/lib/notion_ruby_mapping/objects/user_object.rb +4 -4
  63. data/lib/notion_ruby_mapping/properties/button_property.rb +4 -4
  64. data/lib/notion_ruby_mapping/properties/checkbox_property.rb +3 -3
  65. data/lib/notion_ruby_mapping/properties/created_by_property.rb +3 -3
  66. data/lib/notion_ruby_mapping/properties/created_time_property.rb +2 -2
  67. data/lib/notion_ruby_mapping/properties/date_base_property.rb +14 -13
  68. data/lib/notion_ruby_mapping/properties/date_property.rb +17 -17
  69. data/lib/notion_ruby_mapping/properties/email_property.rb +3 -3
  70. data/lib/notion_ruby_mapping/properties/files_property.rb +16 -13
  71. data/lib/notion_ruby_mapping/properties/formula_property.rb +7 -7
  72. data/lib/notion_ruby_mapping/properties/last_edited_by_property.rb +2 -2
  73. data/lib/notion_ruby_mapping/properties/last_edited_time_property.rb +2 -2
  74. data/lib/notion_ruby_mapping/properties/multi_select_property.rb +15 -15
  75. data/lib/notion_ruby_mapping/properties/number_property.rb +9 -9
  76. data/lib/notion_ruby_mapping/properties/people_property.rb +6 -6
  77. data/lib/notion_ruby_mapping/properties/phone_number_property.rb +4 -4
  78. data/lib/notion_ruby_mapping/properties/property.rb +78 -74
  79. data/lib/notion_ruby_mapping/properties/relation_property.rb +18 -17
  80. data/lib/notion_ruby_mapping/properties/rich_text_property.rb +5 -5
  81. data/lib/notion_ruby_mapping/properties/rollup_property.rb +15 -15
  82. data/lib/notion_ruby_mapping/properties/select_property.rb +14 -14
  83. data/lib/notion_ruby_mapping/properties/status_property.rb +5 -5
  84. data/lib/notion_ruby_mapping/properties/text_property.rb +1 -1
  85. data/lib/notion_ruby_mapping/properties/title_property.rb +6 -6
  86. data/lib/notion_ruby_mapping/properties/unique_id_property.rb +3 -3
  87. data/lib/notion_ruby_mapping/properties/url_property.rb +3 -3
  88. data/lib/notion_ruby_mapping/properties/verification_property.rb +41 -0
  89. data/lib/notion_ruby_mapping/version.rb +1 -1
  90. data/lib/notion_ruby_mapping.rb +1 -1
  91. data/notion_ruby_mapping.gemspec +1 -2
  92. metadata +5 -22
  93. data/sig/notion_ruby_mapping.rbs +0 -4
@@ -3,7 +3,7 @@
3
3
  module NotionRubyMapping
4
4
  # DateProperty
5
5
  class DateProperty < DateBaseProperty
6
- TYPE = "date"
6
+ TYPE = :date
7
7
 
8
8
  ### Public announced methods
9
9
 
@@ -21,12 +21,12 @@ module NotionRubyMapping
21
21
  # @see https://www.notion.so/hkob/DateProperty-c6e815c060cb430889dbb33b697f00c6#15f2088e012549cbae93de14ce14d352
22
22
  def end_date
23
23
  assert_page_property __method__
24
- @json["end"]
24
+ @json[:end]
25
25
  end
26
26
 
27
27
  def end_date_obj
28
28
  assert_page_property __method__
29
- jet = @json["end"]
29
+ jet = @json[:end]
30
30
  case jet
31
31
  when String
32
32
  jet.include?("T") ? Time.parse(jet) : Date.parse(jet)
@@ -42,19 +42,19 @@ module NotionRubyMapping
42
42
  @will_update = true
43
43
  # sdt = start_date
44
44
  # edt = nil if sdt.class != edt.class || sdt > edt
45
- @json["end"] = edt
45
+ @json[:end] = edt
46
46
  end
47
47
 
48
48
  # @return [Date, Time, DateTime, String]
49
49
  # @see https://www.notion.so/hkob/DateProperty-c6e815c060cb430889dbb33b697f00c6#d37097c7a3f7481e9b33a7aaae783888
50
50
  def start_date
51
51
  assert_page_property __method__
52
- @json["start"]
52
+ @json[:start]
53
53
  end
54
54
 
55
55
  def start_date_obj
56
56
  assert_page_property __method__
57
- jst = @json["start"]
57
+ jst = @json[:start]
58
58
  case jst
59
59
  when String
60
60
  jst.include?("T") ? Time.parse(jst) : Date.parse(jst)
@@ -70,14 +70,14 @@ module NotionRubyMapping
70
70
  @will_update = true
71
71
  # edt = end_date
72
72
  # @json["end"] = nil if sdt.class != edt.class || sdt > edt
73
- @json["start"] = sdt
73
+ @json[:start] = sdt
74
74
  end
75
75
 
76
76
  # @return [String]
77
77
  # @see https://www.notion.so/hkob/DateProperty-c6e815c060cb430889dbb33b697f00c6#f892cde82d9a44a0850d69878e31b216
78
78
  def time_zone
79
79
  assert_page_property __method__
80
- @json["time_zone"]
80
+ @json[:time_zone]
81
81
  end
82
82
 
83
83
  # @param [String] tzone
@@ -85,7 +85,7 @@ module NotionRubyMapping
85
85
  def time_zone=(tzone)
86
86
  assert_page_property __method__
87
87
  @will_update = true
88
- @json["time_zone"] = tzone
88
+ @json[:time_zone] = tzone
89
89
  end
90
90
 
91
91
  ### Not public announced methods
@@ -105,9 +105,9 @@ module NotionRubyMapping
105
105
  return if database?
106
106
 
107
107
  @json = json || {}
108
- @json["start"] = start_date if start_date
109
- @json["end"] = end_date if end_date
110
- @json["time_zone"] = time_zone if time_zone
108
+ @json[:start] = start_date if start_date
109
+ @json[:end] = end_date if end_date
110
+ @json[:time_zone] = time_zone if time_zone
111
111
  end
112
112
 
113
113
  ## Page property only methods
@@ -117,11 +117,11 @@ module NotionRubyMapping
117
117
  assert_page_property __method__
118
118
  {
119
119
  @name => {
120
- "type" => "date",
121
- "date" => {
122
- "start" => value_str(@json["start"]),
123
- "end" => value_str(@json["end"]),
124
- "time_zone" => @json["time_zone"],
120
+ type: TYPE.to_s,
121
+ date: {
122
+ start: value_str(@json[:start]),
123
+ end: value_str(@json[:end]),
124
+ time_zone: @json[:time_zone],
125
125
  },
126
126
  },
127
127
  }
@@ -7,7 +7,7 @@ module NotionRubyMapping
7
7
  include ContainsDoesNotContain
8
8
  include StartsWithEndsWith
9
9
  include IsEmptyIsNotEmpty
10
- TYPE = "email"
10
+ TYPE = :email
11
11
 
12
12
  ### Public announced methods
13
13
 
@@ -31,7 +31,7 @@ module NotionRubyMapping
31
31
 
32
32
  ## Common methods
33
33
 
34
- # @param [String] name Property name
34
+ # @param [String, Symbol] name Property name
35
35
  def initialize(name, will_update: false, base_type: :page, json: nil, property_id: nil, property_cache: nil)
36
36
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
37
37
  property_cache: property_cache
@@ -41,7 +41,7 @@ module NotionRubyMapping
41
41
  # @return [Hash]
42
42
  def property_values_json
43
43
  assert_page_property __method__
44
- {@name => {"email" => @json, "type" => "email"}}
44
+ {@name => {email: @json, type: "email"}}
45
45
  end
46
46
  end
47
47
  end
@@ -4,7 +4,7 @@ module NotionRubyMapping
4
4
  # Select property
5
5
  class FilesProperty < Property
6
6
  include IsEmptyIsNotEmpty
7
- TYPE = "files"
7
+ TYPE = :files
8
8
 
9
9
  attr_reader :files
10
10
 
@@ -21,7 +21,10 @@ module NotionRubyMapping
21
21
 
22
22
  def file_names=(file_names = [])
23
23
  array_file_names = Array(file_names)
24
- raise StandardError, "files and file_names must be the same sizes." unless @files.length == array_file_names.length
24
+ unless @files.length == array_file_names.length
25
+ raise StandardError,
26
+ "files and file_names must be the same sizes."
27
+ end
25
28
 
26
29
  @will_update = true
27
30
  @file_names = array_file_names
@@ -31,7 +34,7 @@ module NotionRubyMapping
31
34
 
32
35
  ## Common methods
33
36
 
34
- # @param [String] name Property name
37
+ # @param [String, Symbol] name Property name
35
38
  # @param [String] files files value (optional)
36
39
  def initialize(name, will_update: false, base_type: :page, json: nil, files: [], property_id: nil,
37
40
  property_cache: nil)
@@ -41,7 +44,7 @@ module NotionRubyMapping
41
44
  @files = json || {}
42
45
  elsif json
43
46
  @files = json.map { |sub_json| FileObject.new json: sub_json }
44
- @file_names = json.map { |sub_json| sub_json["name"] }
47
+ @file_names = json.map { |sub_json| sub_json[:name] }
45
48
  elsif !files.empty?
46
49
  @files = Array(files).map { |url| FileObject.file_object url }
47
50
  @file_names = Array(files)
@@ -53,20 +56,20 @@ module NotionRubyMapping
53
56
  # @return [Hash]
54
57
  def property_values_json
55
58
  assert_page_property __method__
56
- if @files.map(&:type).include? "file"
59
+ if @files.map(&:type).include? :file
57
60
  {}
58
61
  else
59
62
  files = @files.map(&:property_values_json)
60
- @file_names&.each_with_index { |name, i| files[i]["name"] = name }
61
- {@name => {"files" => files, "type" => "files"}}
63
+ @file_names&.each_with_index { |name, i| files[i][:name] = name }
64
+ {@name => {files: files, type: "files"}}
62
65
  end
63
66
  end
64
67
 
65
68
  def update_from_json(json)
66
69
  return if database?
67
70
 
68
- @files = json["files"].map { |sub_json| FileObject.new json: sub_json }
69
- @file_names = json["files"].map { |sub_json| sub_json["name"] }
71
+ @files = json[:files].map { |sub_json| FileObject.new json: sub_json }
72
+ @file_names = json[:files].map { |sub_json| sub_json[:name] }
70
73
  @will_update = false
71
74
  self
72
75
  end
@@ -77,10 +80,10 @@ module NotionRubyMapping
77
80
  # @return [Hash]
78
81
  def url_to_hash(url)
79
82
  {
80
- "name" => url,
81
- "type" => "external",
82
- "external" => {
83
- "url" => url,
83
+ name: url,
84
+ type: "external",
85
+ external: {
86
+ url: url,
84
87
  },
85
88
  }
86
89
  end
@@ -6,7 +6,7 @@ module NotionRubyMapping
6
6
  include ContainsDoesNotContain
7
7
  include StartsWithEndsWith
8
8
  include GreaterThanLessThan
9
- TYPE = "formula"
9
+ TYPE = :formula
10
10
 
11
11
  ### Public announced methods
12
12
 
@@ -24,7 +24,7 @@ module NotionRubyMapping
24
24
  # @see https://www.notion.so/hkob/FormulaProperty-d6b22ca70822407a9fef0bac8925cd0d#a24d2a7b99254d2a9226c00153f1d516
25
25
  def formula_expression
26
26
  assert_database_property __method__
27
- @json["expression"]
27
+ @json[:expression]
28
28
  end
29
29
 
30
30
  # @param [String] f_e
@@ -32,14 +32,14 @@ module NotionRubyMapping
32
32
  def formula_expression=(f_e)
33
33
  assert_database_property __method__
34
34
  @will_update = true
35
- @json["expression"] = f_e
35
+ @json[:expression] = f_e
36
36
  end
37
37
 
38
38
  ### Not public announced methods
39
39
 
40
40
  ## Common methods
41
41
 
42
- # @param [String] name
42
+ # @param [String, Symbol] name
43
43
  # @param [Hash] json
44
44
  def initialize(name, will_update: false, base_type: :page, json: nil, formula: nil, property_id: nil,
45
45
  property_cache: nil)
@@ -48,7 +48,7 @@ module NotionRubyMapping
48
48
  @json = json || {}
49
49
  return unless database?
50
50
 
51
- @json["expression"] = formula if formula
51
+ @json[:expression] = formula if formula
52
52
  end
53
53
 
54
54
  ## Database property only methods
@@ -60,7 +60,7 @@ module NotionRubyMapping
60
60
  return ans if ans != {} || !@will_update
61
61
 
62
62
  ans[@name] ||= {}
63
- ans[@name]["formula"] = @json
63
+ ans[@name][:formula] = @json
64
64
  ans
65
65
  end
66
66
 
@@ -77,7 +77,7 @@ module NotionRubyMapping
77
77
 
78
78
  # @return [Hash]
79
79
  def property_schema_json_sub
80
- {"expression" => formula_expression}
80
+ {expression: formula_expression}
81
81
  end
82
82
  end
83
83
  end
@@ -3,7 +3,7 @@
3
3
  module NotionRubyMapping
4
4
  # LastEditedByProperty
5
5
  class LastEditedByProperty < MultiProperty
6
- TYPE = "last_edited_by"
6
+ TYPE = :last_edited_by
7
7
 
8
8
  ### Public announced methods
9
9
 
@@ -37,7 +37,7 @@ module NotionRubyMapping
37
37
  # @param [Hash] json
38
38
  def update_from_json(json)
39
39
  @will_update = false
40
- leb = json["last_edited_by"]
40
+ leb = json[:last_edited_by]
41
41
  @json = database? ? leb : UserObject.new(json: leb)
42
42
  end
43
43
 
@@ -3,7 +3,7 @@
3
3
  module NotionRubyMapping
4
4
  # LastEditedTimeProperty
5
5
  class LastEditedTimeProperty < DateBaseProperty
6
- TYPE = "last_edited_time"
6
+ TYPE = :last_edited_time
7
7
 
8
8
  ### Public announced methods
9
9
 
@@ -19,7 +19,7 @@ module NotionRubyMapping
19
19
 
20
20
  ## Common methods
21
21
 
22
- # @param [String] name Property name
22
+ # @param [String, Symbol] name Property name
23
23
  # @param [String] json last_edited_time value (optional)
24
24
  def initialize(name, will_update: false, base_type: :page, json: nil, property_id: nil, property_cache: nil)
25
25
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
@@ -3,7 +3,7 @@
3
3
  module NotionRubyMapping
4
4
  # MultiSelect property
5
5
  class MultiSelectProperty < MultiProperty
6
- TYPE = "multi_select"
6
+ TYPE = :multi_select
7
7
 
8
8
  ### Public announced methods
9
9
 
@@ -16,8 +16,8 @@ module NotionRubyMapping
16
16
 
17
17
  # @return [Array]
18
18
  def multi_select_names
19
- mshs = @base_type == :page ? @json : @json["options"]
20
- mshs.map { |h| h["name"] }
19
+ mshs = @base_type == :page ? @json : @json[:options]
20
+ mshs.map { |h| h[:name] }
21
21
  end
22
22
 
23
23
  ## Database property only methods
@@ -27,21 +27,21 @@ module NotionRubyMapping
27
27
  # @return [Array] added array
28
28
  # @see https://www.notion.so/hkob/MultiSelectProperty-b90bba1c55d540ba97131bb013d4ca74#bcac830b00e04cb6bf7dbbb110d95667
29
29
  def add_multi_select_option(name:, color:)
30
- edit_multi_select_options << {"name" => name, "color" => color}
30
+ edit_multi_select_options << {name: name, color: color}
31
31
  end
32
32
 
33
33
  # @return [Array] copyed multi select options
34
34
  def edit_multi_select_options
35
35
  assert_database_property __method__
36
36
  @will_update = true
37
- @json["options"] ||= []
37
+ @json[:options] ||= []
38
38
  end
39
39
 
40
40
  # @return [Array]
41
41
  # @see https://www.notion.so/hkob/MultiSelectProperty-b90bba1c55d540ba97131bb013d4ca74#5ff6ec299cf64049bde2416f61b30fa9
42
42
  def multi_select_options
43
43
  assert_database_property __method__
44
- @json["options"] || []
44
+ @json[:options] || []
45
45
  end
46
46
 
47
47
  ## Page property only methods
@@ -51,14 +51,14 @@ module NotionRubyMapping
51
51
  def multi_select=(multi_select)
52
52
  assert_page_property __method__
53
53
  @will_update = true
54
- @json = multi_select ? Array(multi_select).map { |ms| {"name" => ms} } : []
54
+ @json = multi_select ? Array(multi_select).map { |ms| {name: ms} } : []
55
55
  end
56
56
 
57
57
  ### Not public announced methods
58
58
 
59
59
  ## Common methods
60
60
 
61
- # @param [String] name
61
+ # @param [String, Symbol] name
62
62
  # @param [Hash] json
63
63
  # @param [Array<String>, String] multi_select
64
64
  def initialize(name, will_update: false, base_type: :page, json: nil, multi_select: nil,
@@ -66,10 +66,10 @@ module NotionRubyMapping
66
66
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
67
67
  property_cache: property_cache
68
68
  if database?
69
- @json = json || {"options" => []}
69
+ @json = json || {options: []}
70
70
  else
71
71
  @json = json || []
72
- @json = Array(multi_select).map { |ms| {"name" => ms} } unless multi_select.nil?
72
+ @json = Array(multi_select).map { |ms| {name: ms} } unless multi_select.nil?
73
73
  end
74
74
  end
75
75
 
@@ -82,8 +82,8 @@ module NotionRubyMapping
82
82
  return ans if ans != {} || !@will_update
83
83
 
84
84
  ans[@name] ||= {}
85
- ans[@name]["multi_select"] ||= {}
86
- ans[@name]["multi_select"]["options"] = @json["options"]
85
+ ans[@name][:multi_select] ||= {}
86
+ ans[@name][:multi_select][:options] = @json[:options]
87
87
  ans
88
88
  end
89
89
 
@@ -94,8 +94,8 @@ module NotionRubyMapping
94
94
  assert_page_property __method__
95
95
  {
96
96
  @name => {
97
- "type" => "multi_select",
98
- "multi_select" => @json,
97
+ type: "multi_select",
98
+ multi_select: @json,
99
99
  },
100
100
  }
101
101
  end
@@ -106,7 +106,7 @@ module NotionRubyMapping
106
106
 
107
107
  # @return [Hash]
108
108
  def property_schema_json_sub
109
- {"options" => edit_multi_select_options}
109
+ {options: edit_multi_select_options}
110
110
  end
111
111
  end
112
112
  end
@@ -6,7 +6,7 @@ module NotionRubyMapping
6
6
  include EqualsDoesNotEqual
7
7
  include GreaterThanLessThan
8
8
  include IsEmptyIsNotEmpty
9
- TYPE = "number"
9
+ TYPE = :number
10
10
 
11
11
  ### Public announced methods
12
12
 
@@ -24,7 +24,7 @@ module NotionRubyMapping
24
24
  # @see https://www.notion.so/hkob/NumberProperty-964ebc1948074d7ca8340187aa352d40#5e3682ed9e124d518f735b236787d7a7
25
25
  def format
26
26
  assert_database_property __method__
27
- @json["format"]
27
+ @json[:format]
28
28
  end
29
29
 
30
30
  # @param [String] format
@@ -33,7 +33,7 @@ module NotionRubyMapping
33
33
  def format=(format)
34
34
  assert_database_property __method__
35
35
  @will_update = true
36
- @json["format"] = format
36
+ @json[:format] = format
37
37
  end
38
38
 
39
39
  ## Page property only methods
@@ -51,21 +51,21 @@ module NotionRubyMapping
51
51
 
52
52
  ## Common methods
53
53
 
54
- # @param [String] name Property name
54
+ # @param [String, Symbol] name Property name
55
55
  # @param [Float, Integer, Hash] json Number value or format Hash
56
56
  def initialize(name, will_update: false, base_type: :page, json: nil, format: nil, property_id: nil,
57
57
  property_cache: nil)
58
58
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
59
59
  property_cache: property_cache
60
60
  @json = json
61
- @json ||= {"format" => (format || "number")} if database?
61
+ @json ||= {format: format || "number"} if database?
62
62
  end
63
63
 
64
64
  # @param [Hash] json
65
65
  # @return [NotionRubyMapping::NumberProperty]
66
66
  def update_from_json(json)
67
67
  @will_update = false
68
- @json = json["number"]
68
+ @json = json[:number]
69
69
  self
70
70
  end
71
71
 
@@ -78,7 +78,7 @@ module NotionRubyMapping
78
78
  return ans if ans != {} || !@will_update
79
79
 
80
80
  ans[@name] ||= {}
81
- ans[@name]["number"] = @json
81
+ ans[@name][:number] = @json
82
82
  ans
83
83
  end
84
84
 
@@ -87,7 +87,7 @@ module NotionRubyMapping
87
87
  # @return [Hash]
88
88
  def property_values_json
89
89
  assert_page_property __method__
90
- {@name => {"number" => @json, "type" => "number"}}
90
+ {@name => {number: @json, type: "number"}}
91
91
  end
92
92
 
93
93
  protected
@@ -96,7 +96,7 @@ module NotionRubyMapping
96
96
 
97
97
  # @return [Hash]
98
98
  def property_schema_json_sub
99
- {"format" => format}
99
+ {format: format}
100
100
  end
101
101
  end
102
102
  end
@@ -3,7 +3,7 @@
3
3
  module NotionRubyMapping
4
4
  # PeopleProperty class
5
5
  class PeopleProperty < MultiProperty
6
- TYPE = "people"
6
+ TYPE = :people
7
7
 
8
8
  ### Public announced methods
9
9
 
@@ -42,14 +42,14 @@ module NotionRubyMapping
42
42
  def self.people_from_json(json)
43
43
  if json.is_a? Array
44
44
  json.map { |sub_json| UserObject.new json: sub_json }
45
- elsif json["object"] == "list"
45
+ elsif json[:object] == "list"
46
46
  List.new(json: json, type: :property, value: self).select { true }
47
47
  else
48
- json["people"].map { |sub_json| UserObject.new json: sub_json }
48
+ json[:people].map { |sub_json| UserObject.new json: sub_json }
49
49
  end
50
50
  end
51
51
 
52
- # @param [String] name
52
+ # @param [String, Symbol] name
53
53
  # @param [Hash] json
54
54
  # @param [Array] people ids for people
55
55
  def initialize(name, will_update: false, base_type: :page, json: nil, people: nil, property_id: nil,
@@ -74,8 +74,8 @@ module NotionRubyMapping
74
74
  assert_page_property __method__
75
75
  {
76
76
  @name => {
77
- "type" => "people",
78
- "people" => @json.map(&:property_values_json),
77
+ type: "people",
78
+ people: @json.map(&:property_values_json),
79
79
  },
80
80
  }
81
81
  end
@@ -7,7 +7,7 @@ module NotionRubyMapping
7
7
  include ContainsDoesNotContain
8
8
  include StartsWithEndsWith
9
9
  include IsEmptyIsNotEmpty
10
- TYPE = "phone_number"
10
+ TYPE = :phone_number
11
11
 
12
12
  ### Public announced methods
13
13
 
@@ -33,10 +33,10 @@ module NotionRubyMapping
33
33
 
34
34
  ## Common methods
35
35
 
36
- # @param [String] name Property name
36
+ # @param [String, Symbol] name Property name
37
37
  def initialize(name, will_update: false, base_type: :page, json: nil, property_id: nil, property_cache: nil)
38
38
  super name, will_update: will_update, base_type: base_type, property_id: property_id,
39
- property_cache: property_cache
39
+ property_cache: property_cache
40
40
  @json = database? ? {} : json
41
41
  end
42
42
 
@@ -44,7 +44,7 @@ module NotionRubyMapping
44
44
  # @return [Hash]
45
45
  def property_values_json
46
46
  assert_page_property __method__
47
- {@name => {"phone_number" => @json, "type" => "phone_number"}}
47
+ {@name => {phone_number: @json, type: "phone_number"}}
48
48
  end
49
49
  end
50
50
  end