Class: RbsActivesupport::Delegate

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs_activesupport/delegate.rb,
sig/rbs_activesupport/delegate.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace, method, options) ⇒ Delegate



12
13
14
15
16
# File 'lib/rbs_activesupport/delegate.rb', line 12

def initialize(namespace, method, options) #: void
  @namespace = namespace
  @method = method
  @options = options
end

Instance Attribute Details

#methodSymbol (readonly)

: Symbol



6
7
8
# File 'lib/rbs_activesupport/delegate.rb', line 6

def method
  @method
end

#namespaceRBS::Namespace (readonly)

: RBS::Namespace



5
6
7
# File 'lib/rbs_activesupport/delegate.rb', line 5

def namespace
  @namespace
end

#optionsHash[Symbol, untyped] (readonly)

: Hash[Symbol, untyped]



7
8
9
# File 'lib/rbs_activesupport/delegate.rb', line 7

def options
  @options
end

Instance Method Details

#method_nameSymbol

: Symbol



22
23
24
25
26
27
28
29
30
31
# File 'lib/rbs_activesupport/delegate.rb', line 22

def method_name #: Symbol
  case options[:prefix]
  when true
    :"#{to}_#{method}"
  when String, Symbol
    :"#{options[:prefix]}_#{method}"
  else
    method
  end
end

#private?Boolean

: bool



37
38
39
# File 'lib/rbs_activesupport/delegate.rb', line 37

def private? #: bool
  options.fetch(:private, false)
end

#public?Boolean

: bool



33
34
35
# File 'lib/rbs_activesupport/delegate.rb', line 33

def public? #: bool
  !private?
end

#toSymbol

: Symbol



18
19
20
# File 'lib/rbs_activesupport/delegate.rb', line 18

def to #: Symbol
  options[:to]
end