Class: BulkOps::WorkProxy

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/bulk_ops/work_proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ WorkProxy

Returns a new instance of WorkProxy.



8
9
10
11
# File 'lib/bulk_ops/work_proxy.rb', line 8

def initialize *args
  super *args
  place_hold if @work_id
end

Instance Attribute Details

#proxy_errorsObject

Returns the value of attribute proxy_errors.



6
7
8
# File 'lib/bulk_ops/work_proxy.rb', line 6

def proxy_errors
  @proxy_errors
end

Instance Method Details

#lift_holdObject



31
32
33
# File 'lib/bulk_ops/work_proxy.rb', line 31

def lift_hold
  # TODO make it so people can edit the work again
end

#ordered_childrenObject



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/bulk_ops/work_proxy.rb', line 45

def ordered_children
  children = BulkOps::WorkProxy.where(parent_id: id)
  ordered_kids = []
  previous_id = nil
  while ordered_kids.length < children.length do
    next_child = children.find{|child| child.previous_sibling_id == previous_id}
    break if (next_child.nil? or ordered_kids.include?(next_child))
    previous_id = next_child.id
    ordered_kids << next_child
  end
  ordered_kids = ordered_kids + (children - ordered_kids) if (children.length > ordered_kids.length)
  ordered_kids
end

#ordered_siblingsObject



40
41
42
43
# File 'lib/bulk_ops/work_proxy.rb', line 40

def ordered_siblings
  return nil unless (parent = BulkOps::WorkProxy.find(parent_id))
  parent.ordered_children - self
end

#place_holdObject



27
28
29
# File 'lib/bulk_ops/work_proxy.rb', line 27

def place_hold
  # TODO make it so nobody can edit the work
end

#workObject



13
14
15
16
17
18
19
20
21
# File 'lib/bulk_ops/work_proxy.rb', line 13

def work
  return @work if @work
  begin
    @work = ActiveFedora::Base.find(work_id)
  rescue 
    return false
  end
  return @work
end

#work_typeObject



23
24
25
# File 'lib/bulk_ops/work_proxy.rb', line 23

def work_type
  super || operation.work_type || "Work"
end