Class: Actions::SafeContext

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/actions/safe_context.rb

Instance Method Summary collapse

Constructor Details

#initialize(context = {}) ⇒ SafeContext

Returns a new instance of SafeContext.



9
10
11
# File 'lib/actions/safe_context.rb', line 9

def initialize(context = {})
  @context = Context.build(context)
end

Instance Method Details

#input!(name, type: Object, required: false, mutable: false) ⇒ Object



13
14
15
16
# File 'lib/actions/safe_context.rb', line 13

def input!(name, type: Object, required: false, mutable: false)
  attribute!(name, type: type, readonly: !mutable)
  validate!(name, type: type, required: required)
end

#output!(name, type: Object) ⇒ Object



18
19
20
# File 'lib/actions/safe_context.rb', line 18

def output!(name, type: Object)
  attribute!(name, type: type, readonly: false)
end