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 77#### Fixes
88
99* Your contribution here.
10+ * [ #1830 ] ( https://github.com/ruby-grape/grape/pull/1830 ) : Restores self_sanity addresses #1829 - [ @myxoh ] ( https://github.com/myxoh ) .
1011
1112### 1.2.1 (2018/11/28)
1213
Original file line number Diff line number Diff line change @@ -6,12 +6,16 @@ module Grape
66 # should subclass this class in order to build an API.
77 class API
88 # 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
1210
1311 class << self
1412 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+
1519 # When inherited, will create a list of all instances (times the API was mounted)
1620 # It will listen to the setup required to mount that endpoint, and replicate it on any new instance
1721 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
36493649 end
36503650 end
36513651 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
36523670end
You can’t perform that action at this time.
0 commit comments