Class: Connector

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/connector.rb

Instance Method Summary collapse

Instance Method Details

#connectable_with_deletedObject



36
37
38
39
40
41
42
43
# File 'app/models/connector.rb', line 36

def connectable_with_deleted
  c = if connectable_type.constantize.respond_to?(:find_with_deleted)
    connectable_type.constantize.find_with_deleted(connectable_id)
  else
    connectable_type.constantize.find(connectable_id)
  end
  (c && c.class.versioned?) ? c.as_of_version(connectable_version) : c
end

#current_connectableObject



28
29
30
31
32
33
34
# File 'app/models/connector.rb', line 28

def current_connectable
  if versioned?
    connectable.as_of_version(connectable_version) if connectable
  else
    get_connectable
  end
end

#get_connectableObject



45
46
47
48
49
50
51
# File 'app/models/connector.rb', line 45

def get_connectable
  #NOTE: This method only exists to work around a bug
  #If you call connector.connectable and try to use that, 
  #if that connectable has dynamic attributes (a portlet, for example),
  #then you will get a NoMethodError when you try to access a dynamic attribute
  connectable_type.constantize.find(connectable_id)
end

#publishable?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'app/models/connector.rb', line 64

def publishable?
  connectable_type.constantize.publishable?
end

#published?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'app/models/connector.rb', line 60

def published?
  publishable? ? connectable.published? : true
end

#statusObject



53
54
55
# File 'app/models/connector.rb', line 53

def status
  published? ? :published : :draft
end

#status_nameObject



56
57
58
# File 'app/models/connector.rb', line 56

def status_name
  status.to_s.titleize
end

#versioned?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'app/models/connector.rb', line 68

def versioned?
  connectable_type.constantize.versioned?
end