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, FilesProperty, MultiProperty, NumberProperty, SelectProperty, TextProperty
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#will_update ⇒ Object
Returns the value of attribute will_update.
Class Method Summary collapse
-
.create_from_json(key, input_json) ⇒ NotionRubyMapping::Property?
Generated Property object.
Instance Method Summary collapse
-
#initialize(name, json: nil) ⇒ Property
constructor
Generated Property object.
-
#make_filter_query(key, value) ⇒ NotionRubyMapping::Query
Generated Query object.
-
#type ⇒ Symbol
Property type.
Constructor Details
#initialize(name, json: nil) ⇒ Property
9 10 11 12 13 |
# File 'lib/notion_ruby_mapping/property.rb', line 9 def initialize(name, json: nil) @name = name @will_update = false @json = json end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/notion_ruby_mapping/property.rb', line 14 def name @name end |
#will_update ⇒ Object
Returns the value of attribute will_update.
15 16 17 |
# File 'lib/notion_ruby_mapping/property.rb', line 15 def will_update @will_update end |
Class Method Details
.create_from_json(key, input_json) ⇒ NotionRubyMapping::Property?
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/notion_ruby_mapping/property.rb', line 32 def self.create_from_json(key, input_json) keys = input_json.keys if keys.include? "number" NumberProperty.new key, json: input_json["number"] elsif keys.include? "select" SelectProperty.new key, json: input_json["select"] elsif keys.include? "multi_select" MultiSelectProperty.new key, json: input_json["multi_select"] elsif keys.include? "date" DateProperty.new key, json: input_json["date"] else nil end end |
Instance Method Details
#make_filter_query(key, value) ⇒ NotionRubyMapping::Query
20 21 22 |
# File 'lib/notion_ruby_mapping/property.rb', line 20 def make_filter_query(key, value) Query.new(filter: {"property" => @name, type => {key => value}}) end |
#type ⇒ Symbol
25 26 27 |
# File 'lib/notion_ruby_mapping/property.rb', line 25 def type self.class::TYPE end |