Class: Blacklight::Types::Selector

Inherits:
Array show all
Defined in:
app/values/blacklight/types.rb

Instance Method Summary collapse

Methods inherited from Value

coerce

Constructor Details

#initialize(by: nil, block: nil, **kwargs) ⇒ Selector

Returns a new instance of Selector.



85
86
87
88
89
# File 'app/values/blacklight/types.rb', line 85

def initialize(by: nil, block: nil, **kwargs)
  super(**kwargs)
  @by = by
  @block = block
end

Instance Method Details

#cast(input) ⇒ Object



91
92
93
94
95
# File 'app/values/blacklight/types.rb', line 91

def cast(input)
  return super.public_send(@by) unless @block

  super.public_send(@by, &@block)
end