Class: AppRail::Airtable::ApplicationRecord
- Inherits:
-
Airrecord::Table
- Object
- Airrecord::Table
- AppRail::Airtable::ApplicationRecord
- Includes:
- ActiveSupport::Inflector, Steps::Displayable
- Defined in:
- lib/app_rail/airtable/application_record.rb
Class Method Summary collapse
- .airtable_attr(*attributes) ⇒ Object
-
.ar_list_item(text:, detail_text: nil, image: nil, sf_symbol: nil, material_icon: nil) ⇒ Object
Step utilities.
- .ar_stack(text_items:) ⇒ Object
- .base_key ⇒ Object
-
.index(user:) ⇒ Object
Override to provide custom sorting or filtering for index.
- .table_name ⇒ Object
Class Method Details
.airtable_attr(*attributes) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/app_rail/airtable/application_record.rb', line 21 def self.airtable_attr(*attributes) attributes.each do |attribute| define_method(attribute.to_s.snake_case) { self[attribute] } define_method("#{attribute.to_s.snake_case}=") { |value| self[attribute] = value } end end |
.ar_list_item(text:, detail_text: nil, image: nil, sf_symbol: nil, material_icon: nil) ⇒ Object
Step utilities
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/app_rail/airtable/application_record.rb', line 29 def self.ar_list_item(text:, detail_text: nil, image: nil, sf_symbol: nil, material_icon: nil) define_method(:ar_list_item_as_json) do { id: id, text: method_value(text).to_s, detailText: method_value(detail_text).to_s, imageURL: method_value(image), sfSymbolName: method_value(sf_symbol), materialIconName: method_value(material_icon) }.compact end end |
.ar_stack(text_items:) ⇒ Object
42 43 44 45 46 |
# File 'lib/app_rail/airtable/application_record.rb', line 42 def self.ar_stack(text_items:) define_method(:ar_stack_as_json) do text_items.map { |ti| { type: :text, label: ti, text: self[ti].to_s } } end end |
.base_key ⇒ Object
13 14 15 |
# File 'lib/app_rail/airtable/application_record.rb', line 13 def self.base_key ENV.fetch('AIRTABLE_BASE_ID') end |
.index(user:) ⇒ Object
Override to provide custom sorting or filtering for index
51 52 53 |
# File 'lib/app_rail/airtable/application_record.rb', line 51 def self.index(user:) all end |
.table_name ⇒ Object
17 18 19 |
# File 'lib/app_rail/airtable/application_record.rb', line 17 def self.table_name name.pluralize end |