File: base.rb

package info (click to toggle)
ruby-grape-entity 1.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 456 kB
  • sloc: ruby: 3,335; makefile: 6
file content (24 lines) | stat: -rw-r--r-- 483 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

module Grape
  class Entity
    module Delegator
      class Base
        attr_reader :object

        def initialize(object)
          @object = object
        end

        def delegatable?(_attribute)
          true
        end

        def accepts_options?
          # Why not `arity > 1`? It might be negative https://ruby-doc.org/core-2.6.6/Method.html#method-i-arity
          method(:delegate).arity != 1
        end
      end
    end
  end
end