Class: PlanMyStuff::ApplicationRecord
- Inherits:
-
Object
- Object
- PlanMyStuff::ApplicationRecord
- Includes:
- ActiveModel::Attributes, ActiveModel::Dirty, ActiveModel::Model, ActiveModel::Serializers::JSON
- Defined in:
- lib/plan_my_stuff/application_record.rb
Overview
Base class for all PMS domain objects backed by GitHub resources. Provides shared persistence predicates and utility helpers.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#github_response ⇒ Object?
readonly
Raw GitHub API response this record was hydrated from.
Class Method Summary collapse
-
.read_field(obj, field) ⇒ Object
Reads a field from an object that may respond to method calls or hash access.
Instance Method Summary collapse
- #destroyed? ⇒ Boolean
-
#initialize ⇒ ApplicationRecord
constructor
A new instance of ApplicationRecord.
- #new_record? ⇒ Boolean
- #persisted? ⇒ Boolean
Constructor Details
#initialize ⇒ ApplicationRecord
Returns a new instance of ApplicationRecord.
115 116 117 118 119 |
# File 'lib/plan_my_stuff/application_record.rb', line 115 def initialize(**) super @persisted = false @destroyed = false end |
Instance Attribute Details
#github_response ⇒ Object? (readonly)
Returns raw GitHub API response this record was hydrated from. Escape hatch for consuming apps to access fields the gem doesn’t expose.
16 17 18 |
# File 'lib/plan_my_stuff/application_record.rb', line 16 def github_response @github_response end |
Class Method Details
.read_field(obj, field) ⇒ Object
Reads a field from an object that may respond to method calls or hash access.
26 27 28 |
# File 'lib/plan_my_stuff/application_record.rb', line 26 def read_field(obj, field) obj.respond_to?(field) ? obj.public_send(field) : obj[field] end |
Instance Method Details
#destroyed? ⇒ Boolean
132 133 134 |
# File 'lib/plan_my_stuff/application_record.rb', line 132 def destroyed? @destroyed end |
#new_record? ⇒ Boolean
127 128 129 |
# File 'lib/plan_my_stuff/application_record.rb', line 127 def new_record? !@persisted end |
#persisted? ⇒ Boolean
122 123 124 |
# File 'lib/plan_my_stuff/application_record.rb', line 122 def persisted? @persisted end |