Class: PageEz::Parameters

Inherits:
Object
  • Object
show all
Defined in:
lib/page_ez/parameters.rb

Defined Under Namespace

Classes: NullParameters, Parameter

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ Parameters

Returns a new instance of Parameters.



27
28
29
# File 'lib/page_ez/parameters.rb', line 27

def initialize(block)
  @block = block
end

Class Method Details

.build(block) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/page_ez/parameters.rb', line 3

def self.build(block)
  if block&.respond_to?(:parameters) && block&.respond_to?(:arity)
    new(block)
  else
    NullParameters.new
  end
end

Instance Method Details

#keyword_argsObject



11
12
13
14
15
16
# File 'lib/page_ez/parameters.rb', line 11

def keyword_args
  @block.parameters.filter_map do |type, name|
    param = Parameter.new(type, name)
    param.name if param.kwarg?
  end
end

#non_keyword_argsObject



18
19
20
21
22
23
# File 'lib/page_ez/parameters.rb', line 18

def non_keyword_args
  @block.parameters.filter_map do |type, name|
    param = Parameter.new(type, name)
    param.name if !param.kwarg?
  end
end