Module: LcpRuby::DataSource::ApiModelConcern
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/lcp_ruby/data_source/api_model_concern.rb
Overview
Concern included into API-backed model classes (instead of ActiveRecord::Base). Provides ActiveModel compatibility and data source delegation.
Instance Method Summary collapse
- #[](attr_name) ⇒ Object
- #destroyed? ⇒ Boolean
- #error? ⇒ Boolean
- #marked_for_destruction? ⇒ Boolean
-
#new_record? ⇒ Boolean
AR compatibility for views.
- #read_attribute(attr_name) ⇒ Object
- #to_label ⇒ Object
- #to_param ⇒ Object
Instance Method Details
#[](attr_name) ⇒ Object
109 110 111 |
# File 'lib/lcp_ruby/data_source/api_model_concern.rb', line 109 def [](attr_name) read_attribute(attr_name) end |
#destroyed? ⇒ Boolean
122 123 124 |
# File 'lib/lcp_ruby/data_source/api_model_concern.rb', line 122 def destroyed? false end |
#error? ⇒ Boolean
113 114 115 |
# File 'lib/lcp_ruby/data_source/api_model_concern.rb', line 113 def error? false end |
#marked_for_destruction? ⇒ Boolean
126 127 128 |
# File 'lib/lcp_ruby/data_source/api_model_concern.rb', line 126 def marked_for_destruction? false end |
#new_record? ⇒ Boolean
AR compatibility for views
118 119 120 |
# File 'lib/lcp_ruby/data_source/api_model_concern.rb', line 118 def new_record? !persisted? end |
#read_attribute(attr_name) ⇒ Object
105 106 107 |
# File 'lib/lcp_ruby/data_source/api_model_concern.rb', line 105 def read_attribute(attr_name) send(attr_name) if respond_to?(attr_name) end |
#to_label ⇒ Object
101 102 103 |
# File 'lib/lcp_ruby/data_source/api_model_concern.rb', line 101 def to_label to_s end |
#to_param ⇒ Object
97 98 99 |
# File 'lib/lcp_ruby/data_source/api_model_concern.rb', line 97 def to_param id&.to_s end |