Cross Reference: action.rb
xref
: /
ontohub
/
app
/
models
/
action.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
action.rb revision 56daed0ee72efa88b1e88dd30c168015df4e2e59
class
Action
<
ActiveRecord
::
Base
belongs_to
:
resource
,
polymorphic
:
true
attr_accessible
:
initial_eta
, :
resource
def
self.enclose
!
(
initial_eta
,
klass
,
method
, *
args
)
action
=
create
!
(
initial_eta
:
initial_eta
)
ActionWorker.perform
_async
(
action.id
,
klass.to
_s
,
method
, *
args
)
action
end
def
eta
(
time
=
Time.now
)
diff
=
(
created_at
+
initial_eta
)
-
time
[
diff
,
0
].
max
end
def
status
if
resource.nil
?
'waiting'
elsif
resource.respond
_to
?
(:
state
)
resource.state
elsif
resource.respond
_to
?
(:
status
)
resource.status
else
raise
NoMethodError
,
"resource does know neither state nor status."
end
end
end