Class: NotionRubyMapping::FilesProperty
- Includes:
- IsEmptyIsNotEmpty
- Defined in:
- lib/notion_ruby_mapping/files_property.rb
Overview
Select property
Constant Summary collapse
- TYPE =
"files"
Instance Attribute Summary
Attributes inherited from Property
Instance Method Summary collapse
- #files ⇒ Hash
-
#files=(files = []) ⇒ Object
Page property only methods.
-
#initialize(name, will_update: false, base_type: :page, json: nil, files: []) ⇒ FilesProperty
constructor
A new instance of FilesProperty.
- #property_values_json ⇒ Hash
Methods included from IsEmptyIsNotEmpty
#filter_is_empty, #filter_is_not_empty
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, #remove, #type, #update_from_json, #update_property_schema_json
Constructor Details
#initialize(name, will_update: false, base_type: :page, json: nil, files: []) ⇒ FilesProperty
Returns a new instance of FilesProperty.
31 32 33 34 35 36 37 38 39 |
# File 'lib/notion_ruby_mapping/files_property.rb', line 31 def initialize(name, will_update: false, base_type: :page, json: nil, files: []) super name, will_update: will_update, base_type: base_type if database? @json = json || {} else @json = json || [] @json = Array(files).map { |url| url_to_hash url } unless files.empty? end end |
Instance Method Details
#files ⇒ Hash
14 15 16 |
# File 'lib/notion_ruby_mapping/files_property.rb', line 14 def files @json end |
#files=(files = []) ⇒ Object
Page property only methods
20 21 22 23 |
# File 'lib/notion_ruby_mapping/files_property.rb', line 20 def files=(files = []) @will_update = true @json = Array(files).map { |url| url_to_hash url } end |
#property_values_json ⇒ Hash
42 43 44 45 46 47 48 49 |
# File 'lib/notion_ruby_mapping/files_property.rb', line 42 def property_values_json assert_page_property __method__ if @json.map { |f| f["type"] }.include? "file" {} else {@name => {"files" => @json, "type" => "files"}} end end |