Less code
parent
54f172c2f5
commit
2af0e6330c
|
@ -14,27 +14,12 @@ module Sequences
|
|||
end
|
||||
|
||||
def validate
|
||||
read_users_mind
|
||||
add_error(:steps, :empty, "Can't be blank") if steps == []
|
||||
raise Errors::Forbidden unless sequence.device.users.include?(user)
|
||||
end
|
||||
|
||||
def execute
|
||||
update_attributes(sequence, inputs.except(:user, :sequence, :_id))
|
||||
end
|
||||
|
||||
def read_users_mind
|
||||
case steps
|
||||
when nil
|
||||
# User doesn't want to touch the steps.
|
||||
nil
|
||||
when []
|
||||
# User wants to empty the step list
|
||||
# This is not legal, but we let it pass through for the sake of
|
||||
# generating coherent, readable errors
|
||||
add_error(:steps, :empty, "Can't be blank")
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue