Class: NotionRubyMapping::Property
- Inherits:
-
Object
- Object
- NotionRubyMapping::Property
- Defined in:
- lib/notion_ruby_mapping/property.rb
Overview
abstract class for property
Direct Known Subclasses
CheckboxProperty, DateBaseProperty, EmailProperty, FilesProperty, MultiProperty, NumberProperty, PhoneNumberProperty, SelectProperty, TextProperty, UrlProperty
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
- #will_update ⇒ TrueClass, FalseClass readonly
Class Method Summary collapse
-
.create_from_json(name, input_json) ⇒ NotionRubyMapping::Property?
Generated Property object.
Instance Method Summary collapse
-
#initialize(name, will_update: false) ⇒ Property
constructor
Generated Property object.
-
#make_filter_query(key, value, rollup = nil, rollup_type = nil) ⇒ NotionRubyMapping::Query
Generated Query object.
-
#type ⇒ Symbol
Property type.
Constructor Details
#initialize(name, will_update: false) ⇒ Property
Returns generated Property object.
8 9 10 11 |
# File 'lib/notion_ruby_mapping/property.rb', line 8 def initialize(name, will_update: false) @name = name @will_update = will_update end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/notion_ruby_mapping/property.rb', line 12 def name @name end |
#will_update ⇒ TrueClass, FalseClass (readonly)
15 16 17 |
# File 'lib/notion_ruby_mapping/property.rb', line 15 def will_update @will_update end |
Class Method Details
.create_from_json(name, input_json) ⇒ NotionRubyMapping::Property?
Returns generated Property object.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/notion_ruby_mapping/property.rb', line 36 def self.create_from_json(name, input_json) raise StandardError, "Property not found: #{name}:#{input_json}" if input_json.nil? case input_json["type"] when "number" NumberProperty.new name, number: input_json["number"] when "select" SelectProperty.new name, json: input_json["select"] when "multi_select" MultiSelectProperty.new name, json: input_json["multi_select"] when "date" DateProperty.new name, json: input_json["date"] when "title" TitleProperty.new name, json: input_json["title"] when "rich_text" RichTextProperty.new name, json: input_json["rich_text"] when "checkbox" CheckboxProperty.new name, checkbox: input_json["checkbox"] when "people" PeopleProperty.new name, json: input_json["people"] when "email" EmailProperty.new name, email: input_json["email"] when "url" UrlProperty.new name, url: input_json["url"] when "phone_number" PhoneNumberProperty.new name, phone_number: input_json["phone_number"] when "files" FilesProperty.new name, json: input_json["files"] when "created_time" CreatedTimeProperty.new name, created_time: input_json["created_time"] when "last_edited_time" LastEditedTimeProperty.new name, last_edited_time: input_json["last_edited_time"] when "created_by" CreatedByProperty.new name, json: input_json["created_by"] when "last_edited_by" LastEditedByProperty.new name, json: input_json["last_edited_by"] when "formula" FormulaProperty.new name, json: input_json["formula"] when "rollup" RollupProperty.new name, json: input_json["rollup"] when "relation" RelationProperty.new name, json: input_json["relation"] else raise StandardError, "Irregular property type: #{input_json["type"]}" end end |
Instance Method Details
#make_filter_query(key, value, rollup = nil, rollup_type = nil) ⇒ NotionRubyMapping::Query
Returns generated Query object.
20 21 22 23 24 25 26 |
# File 'lib/notion_ruby_mapping/property.rb', line 20 def make_filter_query(key, value, rollup = nil, rollup_type = nil) if rollup Query.new filter: {"property" => @name, rollup => {rollup_type => {key => value}}} else Query.new filter: {"property" => @name, type => {key => value}} end end |
#type ⇒ Symbol
Returns property type.
29 30 31 |
# File 'lib/notion_ruby_mapping/property.rb', line 29 def type self.class::TYPE end |