Class: PlanMyStuff::ApplicationRecord

Inherits:
Object
  • Object
show all
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

BaseProject, BaseProjectItem, Comment, Issue, Label

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApplicationRecord

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_responseObject? (readonly)

Returns raw GitHub API response this record was hydrated from. Escape hatch for consuming apps to access fields the gem doesn’t expose.

Returns:

  • (Object, nil)

    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.

Parameters:

  • obj (Object)
  • field (Symbol)

Returns:

  • (Object)


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

Returns:

  • (Boolean)


132
133
134
# File 'lib/plan_my_stuff/application_record.rb', line 132

def destroyed?
  @destroyed
end

#new_record?Boolean

Returns:

  • (Boolean)


127
128
129
# File 'lib/plan_my_stuff/application_record.rb', line 127

def new_record?
  !@persisted
end

#persisted?Boolean

Returns:

  • (Boolean)


122
123
124
# File 'lib/plan_my_stuff/application_record.rb', line 122

def persisted?
  @persisted
end