Class: Rack::RPC::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/rpc/server.rb

Overview

Server

Direct Known Subclasses

MethodCommand, ProcCommand

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Command

Returns a new instance of Command.



76
77
78
79
80
81
82
83
# File 'lib/rack/rpc/server.rb', line 76

def initialize(options)
  @options = options

  # Convert non-array options to arrays
  [:only, :except].each do |option|
    options[option] = [options[option]] if !options[option].nil? && !options[option].is_a?(Array)
  end
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



74
75
76
# File 'lib/rack/rpc/server.rb', line 74

def options
  @options
end

Instance Method Details

#callable?(method) ⇒ Boolean

Returns:

  • (Boolean)


85
86
87
88
89
# File 'lib/rack/rpc/server.rb', line 85

def callable?(method)
  options.empty? ||
  (!options[:only].nil? && options[:only].include?(method)) ||
  (!options[:except].nil? && !options[:except].include?(method))
end