Class: ParamsReady::QueryContext

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Restriction::Wrapper
Defined in:
lib/params_ready/query_context.rb

Instance Attribute Summary collapse

Attributes included from Restriction::Wrapper

#restriction

Instance Method Summary collapse

Methods included from Restriction::Wrapper

#delegate, #for_children, #permit, #permit_all, #prohibit, #to_restriction

Constructor Details

#initialize(restriction, data = {}) ⇒ QueryContext

Returns a new instance of QueryContext.

Raises:



11
12
13
14
15
# File 'lib/params_ready/query_context.rb', line 11

def initialize(restriction, data = {})
  @data = data.freeze
  raise ParamsReadyError, "Restriction expected, got: #{restriction.inspect}" unless restriction.is_a? Restriction
  @restriction = restriction.freeze
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



8
9
10
# File 'lib/params_ready/query_context.rb', line 8

def data
  @data
end

Instance Method Details

#clone(restriction:) ⇒ Object



17
18
19
# File 'lib/params_ready/query_context.rb', line 17

def clone(restriction:)
  QueryContext.new restriction, data
end