Skip to content

Commit

Permalink
Fix #1044: move #ordered_by method to concern
Browse files Browse the repository at this point in the history
Remove BaseRecord for AR models and move #ordered_by method to concerns
so anyone who patches default models can reopen them.
  • Loading branch information
nbulaj committed Mar 1, 2018
1 parent 0be34a2 commit de560c2
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 16 deletions.
13 changes: 13 additions & 0 deletions lib/doorkeeper/models/concerns/orderable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Doorkeeper
module Models
module Orderable
extend ActiveSupport::Concern

module ClassMethods
def ordered_by(attribute, direction = :asc)
order(attribute => direction)
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/doorkeeper/orm/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Orm
module ActiveRecord
def self.initialize_models!
lazy_load do
require 'doorkeeper/orm/active_record/base_record'
require 'doorkeeper/models/concerns/orderable'
require 'doorkeeper/orm/active_record/access_grant'
require 'doorkeeper/orm/active_record/access_token'
require 'doorkeeper/orm/active_record/application'
Expand Down
3 changes: 2 additions & 1 deletion lib/doorkeeper/orm/active_record/access_grant.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module Doorkeeper
class AccessGrant < BaseRecord
class AccessGrant < ActiveRecord::Base
self.table_name = "#{table_name_prefix}oauth_access_grants#{table_name_suffix}".to_sym

include Models::Orderable
include AccessGrantMixin
include ActiveModel::MassAssignmentSecurity if defined?(::ProtectedAttributes)

Expand Down
3 changes: 2 additions & 1 deletion lib/doorkeeper/orm/active_record/access_token.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module Doorkeeper
class AccessToken < BaseRecord
class AccessToken < ActiveRecord::Base
self.table_name = "#{table_name_prefix}oauth_access_tokens#{table_name_suffix}".to_sym

include Models::Orderable
include AccessTokenMixin
include ActiveModel::MassAssignmentSecurity if defined?(::ProtectedAttributes)

Expand Down
3 changes: 2 additions & 1 deletion lib/doorkeeper/orm/active_record/application.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module Doorkeeper
class Application < BaseRecord
class Application < ActiveRecord::Base
self.table_name = "#{table_name_prefix}oauth_applications#{table_name_suffix}".to_sym

include Models::Orderable
include ApplicationMixin
include ActiveModel::MassAssignmentSecurity if defined?(::ProtectedAttributes)

Expand Down
11 changes: 0 additions & 11 deletions lib/doorkeeper/orm/active_record/base_record.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/doorkeeper/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module VERSION
# Semantic versioning
MAJOR = 4
MINOR = 3
TINY = 0
TINY = 1

# Full version number
STRING = [MAJOR, MINOR, TINY].compact.join('.')
Expand Down

1 comment on commit de560c2

@stevenharman
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.