-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
pikesley
committed
Feb 25, 2016
1 parent
210bc34
commit f68274a
Showing
11 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
class BloodPressure < ActiveRecord::Base | ||
include PresenterExtension | ||
|
||
def self.short_name | ||
'Blood Pressure' | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
class CarbohydrateIntake < ActiveRecord::Base | ||
include PresenterExtension | ||
|
||
def self.short_name | ||
'Carbs' | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module PresenterExtension | ||
extend ActiveSupport::Concern | ||
|
||
module ClassMethods | ||
def presenter | ||
GlucoseMeasurementPresenter | ||
end | ||
end | ||
end | ||
|
||
ActiveRecord::Base.send(:include, PresenterExtension) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
class GlucoseMeasurement < ActiveRecord::Base | ||
include PresenterExtension | ||
|
||
def self.short_name | ||
'Glucose' | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
class GlycatedHaemoglobin < ActiveRecord::Base | ||
include PresenterExtension | ||
|
||
def self.short_name | ||
'HbA1c' | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
class MedicationEvent < ActiveRecord::Base | ||
include PresenterExtension | ||
|
||
def self.short_name | ||
'Meds' | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
class PhysicalExercise < ActiveRecord::Base | ||
include PresenterExtension | ||
|
||
def self.short_name | ||
'Exercise' | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,6 +107,10 @@ def wrapped_model | |
} | ||
end | ||
|
||
def short_name | ||
model.class.short_name | ||
end | ||
|
||
private | ||
|
||
def model | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<h1>Add <%= class_name(@metric).short_name %></h1> | ||
<% @decorated_metric = "#{@metric.class.name}Presenter".constantize.new @metric %> | ||
<h1>Add <%= @decorated_metric.short_name %></h1> | ||
|
||
<%= render partial: 'shared/form' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
describe GlucoseMeasurement, type: :model do | ||
it 'knows what its presenter is' do | ||
expect(described_class.presenter).to eq GlucoseMeasurementPresenter | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters