Class: RbsActivesupport::Delegate

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace, method, options) ⇒ Delegate

Returns a new instance of 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

#methodObject (readonly)

: Symbol



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

def method
  @method
end

#namespaceObject (readonly)

: RBS::Namespace



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

def namespace
  @namespace
end

#optionsObject (readonly)

: Hash[Symbol, untyped]



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

def options
  @options
end

Instance Method Details

#method_nameObject

: 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

Returns:

  • (Boolean)


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

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

#public?Boolean

: bool

Returns:

  • (Boolean)


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

def public? #: bool
  !private?
end

#toObject

: Symbol



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

def to #: Symbol
  options[:to]
end