Class: NotionRubyMapping::StatusProperty
- Includes:
- EqualsDoesNotEqual, IsEmptyIsNotEmpty
- Defined in:
- lib/notion_ruby_mapping/properties/status_property.rb
Overview
Status property
Constant Summary collapse
- TYPE =
"status"
Instance Attribute Summary
Attributes inherited from Property
#name, #property_cache, #property_id, #will_update
Instance Method Summary collapse
-
#add_status_option(name:, color:, group: nil) ⇒ Array<Hash>
Database or DataSource property only methods.
-
#edit_status_options ⇒ Array<Hash>
Editable status options.
-
#initialize(name, will_update: false, base_type: "page", property_id: nil, property_cache: nil, json: {}) ⇒ StatusProperty
constructor
A new instance of StatusProperty.
- #property_schema_json_sub ⇒ Hash
- #property_values_json ⇒ Hash
- #status ⇒ Object
- #status=(status) ⇒ Object
- #status_name ⇒ String
-
#status_names ⇒ Array<String>
Status option names.
-
#status_options ⇒ Array<Hash>
Status options.
- #update_property_schema_json ⇒ Hash
Methods included from IsEmptyIsNotEmpty
#filter_is_empty, #filter_is_not_empty
Methods included from EqualsDoesNotEqual
#filter_does_not_equal, #filter_equals
Methods inherited from Property
#assert_data_source_property, #assert_database_or_data_source_property, #assert_page_property, #clear_will_update, create_from_json, #data_source?, #database?, #database_or_data_source?, #make_filter_query, #new_name=, #page?, #property_schema_json, #remove, #retrieve_page_property, #type, #update_from_json
Constructor Details
#initialize(name, will_update: false, base_type: "page", property_id: nil, property_cache: nil, json: {}) ⇒ StatusProperty
Returns a new instance of StatusProperty.
71 72 73 74 75 |
# File 'lib/notion_ruby_mapping/properties/status_property.rb', line 71 def initialize(name, will_update: false, base_type: "page", property_id: nil, property_cache: nil, json: {}) super name, will_update: will_update, base_type: base_type, property_id: property_id, property_cache: property_cache @json = json end |
Instance Method Details
#add_status_option(name:, color:, group: nil) ⇒ Array<Hash>
Database or DataSource property only methods
40 41 42 43 44 |
# File 'lib/notion_ruby_mapping/properties/status_property.rb', line 40 def add_status_option(name:, color:, group: nil) hash = {"name" => name, "color" => color} hash["group"] = group if group << hash end |
#edit_status_options ⇒ Array<Hash>
Returns editable status options.
47 48 49 50 51 |
# File 'lib/notion_ruby_mapping/properties/status_property.rb', line 47 def assert_database_or_data_source_property __method__ @will_update = true @json["edit_options"] ||= [] end |
#property_schema_json_sub ⇒ Hash
102 103 104 |
# File 'lib/notion_ruby_mapping/properties/status_property.rb', line 102 def property_schema_json_sub @json["edit_options"] ? {"options" => @json["edit_options"]} : {} end |
#property_values_json ⇒ Hash
80 81 82 83 |
# File 'lib/notion_ruby_mapping/properties/status_property.rb', line 80 def property_values_json assert_page_property __method__ {@name => {"status" => @json, "type" => "status"}} end |
#status ⇒ Object
15 16 17 |
# File 'lib/notion_ruby_mapping/properties/status_property.rb', line 15 def status @json end |
#status=(status) ⇒ Object
30 31 32 33 34 |
# File 'lib/notion_ruby_mapping/properties/status_property.rb', line 30 def status=(status) assert_page_property __method__ @will_update = true @json = {"name" => status} end |
#status_name ⇒ String
23 24 25 26 |
# File 'lib/notion_ruby_mapping/properties/status_property.rb', line 23 def status_name assert_page_property __method__ @json["name"] end |
#status_names ⇒ Array<String>
Returns status option names.
60 61 62 63 |
# File 'lib/notion_ruby_mapping/properties/status_property.rb', line 60 def status_names assert_database_or_data_source_property __method__ .map { |s| s["name"] } end |
#status_options ⇒ Array<Hash>
Returns status options.
54 55 56 57 |
# File 'lib/notion_ruby_mapping/properties/status_property.rb', line 54 def assert_database_or_data_source_property __method__ @json["options"] || [] end |
#update_property_schema_json ⇒ Hash
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/notion_ruby_mapping/properties/status_property.rb', line 88 def update_property_schema_json assert_database_or_data_source_property __method__ ans = super return ans if ans != {} || !@will_update ans[@name] ||= {} ans[@name]["status"] ||= {} ans[@name]["status"]["options"] = @json["edit_options"] ans end |