Class: Operationable::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/operationable.rb,
lib/operationable/operation.rb

Defined Under Namespace

Classes: Builder, Callback, Delayer, Serializer, Specification

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record, user, params = {}) ⇒ Operation

Returns a new instance of Operation.



6
7
8
9
10
# File 'lib/operationable/operation.rb', line 6

def initialize(record, user, params={})
  @record = record
  @user = user
  @params = params
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



4
5
6
# File 'lib/operationable/operation.rb', line 4

def params
  @params
end

#recordObject (readonly)

Returns the value of attribute record.



4
5
6
# File 'lib/operationable/operation.rb', line 4

def record
  @record
end

#resultObject (readonly)

Returns the value of attribute result.



4
5
6
# File 'lib/operationable/operation.rb', line 4

def result
  @result
end

#userObject (readonly)

Returns the value of attribute user.



4
5
6
# File 'lib/operationable/operation.rb', line 4

def user
  @user
end

Instance Method Details

#processObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/operationable/operation.rb', line 12

def process
  return false unless valid

  @result = build

  return false unless persist

  run

  record.reload
end