File tree Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 7
7
#### Fixes
8
8
9
9
* Your contribution here.
10
+ * [ #1830 ] ( https://github.com/ruby-grape/grape/pull/1830 ) : Restores self_sanity addresses #1829 - [ @myxoh ] ( https://github.com/myxoh ) .
10
11
11
12
### 1.2.1 (2018/11/28)
12
13
Original file line number Diff line number Diff line change @@ -6,12 +6,16 @@ module Grape
6
6
# should subclass this class in order to build an API.
7
7
class API
8
8
# Class methods that we want to call on the API rather than on the API object
9
- NON_OVERRIDABLE = %I[ define_singleton_method instance_variable_set inspect class is_a? ! kind_of?
10
- respond_to? respond_to_missing? const_defined? const_missing parent
11
- parent_name name equal? to_s parents anonymous? ] . freeze
9
+ NON_OVERRIDABLE = Class . new . methods . freeze
12
10
13
11
class << self
14
12
attr_accessor :base_instance , :instances
13
+
14
+ # Rather than initializing an object of type Grape::API, create an object of type Instance
15
+ def new ( *args , &block )
16
+ base_instance . new ( *args , &block )
17
+ end
18
+
15
19
# When inherited, will create a list of all instances (times the API was mounted)
16
20
# It will listen to the setup required to mount that endpoint, and replicate it on any new instance
17
21
def inherited ( api , base_instance_parent = Grape ::API ::Instance )
Original file line number Diff line number Diff line change @@ -3649,4 +3649,22 @@ def before
3649
3649
end
3650
3650
end
3651
3651
end
3652
+
3653
+ describe 'normal class methods' do
3654
+ subject ( :grape_api ) { Class . new ( Grape ::API ) }
3655
+
3656
+ before do
3657
+ stub_const ( 'MyAPI' , grape_api )
3658
+ end
3659
+
3660
+ it 'can find the appropiate name' do
3661
+ expect ( grape_api . name ) . to eq 'MyAPI'
3662
+ end
3663
+
3664
+ it 'is equal to itself' do
3665
+ expect ( grape_api . itself ) . to eq grape_api
3666
+ expect ( grape_api ) . to eq MyAPI
3667
+ expect ( grape_api . eql? ( MyAPI ) )
3668
+ end
3669
+ end
3652
3670
end
You can’t perform that action at this time.
0 commit comments