Sha256: f9edd8cc27827c3df5dcd7cedd0941712c6dc04032abe6ed8784c79fdfbfdd5b

Contents?: true

Size: 839 Bytes

Versions: 7

Compression:

Stored size: 839 Bytes

Contents

# frozen_string_literal: true

module RbsActivesupport
  class Delegate
    attr_reader :namespace #: RBS::Namespace
    attr_reader :method #: Symbol
    attr_reader :options #: Hash[Symbol, untyped]

    # @rbs namespace: RBS::Namespace
    # @rbs method: Symbol
    # @rbs options: Hash[Symbol, untyped]
    def initialize(namespace, method, options) #: void
      @namespace = namespace
      @method = method
      @options = options
    end

    def to #: Symbol
      options[:to]
    end

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

    def public? #: bool
      !private?
    end

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rbs_activesupport-1.4.3 lib/rbs_activesupport/delegate.rb
rbs_activesupport-1.4.2 lib/rbs_activesupport/delegate.rb
rbs_activesupport-1.4.1 lib/rbs_activesupport/delegate.rb
rbs_activesupport-1.4.0 lib/rbs_activesupport/delegate.rb
rbs_activesupport-1.3.0 lib/rbs_activesupport/delegate.rb
rbs_activesupport-1.2.1 lib/rbs_activesupport/delegate.rb
rbs_activesupport-1.2.0 lib/rbs_activesupport/delegate.rb