Skip to content

Commit

Permalink
Insert an interface layer for object_inspector gem use
Browse files Browse the repository at this point in the history
Add ObjectInspectionBehaviors -- an interface layer to the inspection
helper in the object_inspector gem. Using this approach, we are able to
e.g. conditionally enable object_inspector throughout the entire app.
  • Loading branch information
Paul DobbinSchmaltz committed Nov 15, 2024
1 parent 992138f commit 0f23b59
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/models/board.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def validate_settings
end

concerning :ObjectInspection do
include ObjectInspector::InspectorsHelper
include ObjectInspectionBehaviors

def inspect_identification = identify

Expand Down
2 changes: 1 addition & 1 deletion app/models/board/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def as_json = to_h
def to_a = to_h.values

concerning :ObjectInspection do
include ObjectInspector::InspectorsHelper
include ObjectInspectionBehaviors

def inspect_identification = identify(:width, :height, :mines)

Expand Down
6 changes: 3 additions & 3 deletions app/models/calc_3bv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def process_cells
def count = cells.sum(&:count)

concerning :ObjectInspection do
include ObjectInspector::InspectorsHelper
include ObjectInspectionBehaviors

def inspect_identification = identify(:grid)
end
Expand Down Expand Up @@ -103,7 +103,7 @@ def neighbors = calculator.cells_at(neighboring_coordinates)
def neighboring_coordinates = coordinates.neighbors

concerning :ObjectInspection do
include ObjectInspector::InspectorsHelper
include ObjectInspectionBehaviors

def inspect_flags(scope:)
scope.join_flags([
Expand Down Expand Up @@ -146,7 +146,7 @@ def render
def grid = super.console

concerning :ObjectInspection do
include ObjectInspector::InspectorsHelper
include ObjectInspectionBehaviors

def inspect_identification = identify(:grid, klass: __class__)
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def neighboring_flags_count
end

concerning :ObjectInspection do
include ObjectInspector::InspectorsHelper
include ObjectInspectionBehaviors

def inspect_identification = identify

Expand Down
2 changes: 1 addition & 1 deletion app/models/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def set_stats
end

concerning :ObjectInspection do
include ObjectInspector::InspectorsHelper
include ObjectInspectionBehaviors

def inspect_identification = identify

Expand Down
2 changes: 1 addition & 1 deletion app/models/grid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def organizer
end

concerning :ObjectInspection do
include ObjectInspector::InspectorsHelper
include ObjectInspectionBehaviors

def inspect_identification = self.class.name

Expand Down
2 changes: 1 addition & 1 deletion app/models/pattern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def validate_settings
end

concerning :ObjectInspection do
include ObjectInspector::InspectorsHelper
include ObjectInspectionBehaviors

def inspect_identification = identify

Expand Down
2 changes: 1 addition & 1 deletion app/models/pattern/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def to_a = to_h.values
def as_json = to_h

concerning :ObjectInspection do
include ObjectInspector::InspectorsHelper
include ObjectInspectionBehaviors

def inspect_identification = identify(:width, :height)
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/transactions/cell_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def self.exists_between?(user:, cell:)
end

concerning :ObjectInspection do
include ObjectInspector::InspectorsHelper
include ObjectInspectionBehaviors

def inspect_identification = identify

Expand Down
2 changes: 1 addition & 1 deletion app/models/transactions/game_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def self.exists_between?(user:, game:)
end

concerning :ObjectInspection do
include ObjectInspector::InspectorsHelper
include ObjectInspectionBehaviors

def inspect_identification = identify

Expand Down
2 changes: 1 addition & 1 deletion app/models/transactions/user_update_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def self.create_for(user:, change_set:)
end

concerning :ObjectInspection do
include ObjectInspector::InspectorsHelper
include ObjectInspectionBehaviors

def inspect_identification = identify

Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def completed_games_count
def bests = @bests ||= Bests.new(self)

concerning :ObjectInspection do
include ObjectInspector::InspectorsHelper
include ObjectInspectionBehaviors

def inspect_identification = identify(:truncated_id)
def truncated_id = id[TRUNCATED_ID_RANGE]
Expand Down
10 changes: 10 additions & 0 deletions lib/object_inspection_behaviors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

# ObjectInspectionBehaviors is an interface layer to the inspection helper in
# the object_inspector gem. Using this approach, we are able to e.g.
# conditionally enable object_inspector throughout the entire app.
module ObjectInspectionBehaviors
unless App.debug? # rubocop:disable Style/IfUnlessModifier
include ObjectInspector::InspectorsHelper
end
end

0 comments on commit 0f23b59

Please sign in to comment.