Class: Connector
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Connector
- Defined in:
- app/models/connector.rb
Instance Method Summary collapse
- #connectable_with_deleted ⇒ Object
- #current_connectable ⇒ Object
- #get_connectable ⇒ Object
- #publishable? ⇒ Boolean
- #published? ⇒ Boolean
- #status ⇒ Object
- #status_name ⇒ Object
- #versioned? ⇒ Boolean
Instance Method Details
#connectable_with_deleted ⇒ Object
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_connectable ⇒ Object
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_connectable ⇒ Object
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
64 65 66 |
# File 'app/models/connector.rb', line 64 def publishable? connectable_type.constantize.publishable? end |
#published? ⇒ Boolean
60 61 62 |
# File 'app/models/connector.rb', line 60 def published? publishable? ? connectable.published? : true end |
#status ⇒ Object
53 54 55 |
# File 'app/models/connector.rb', line 53 def status published? ? :published : :draft end |
#status_name ⇒ Object
56 57 58 |
# File 'app/models/connector.rb', line 56 def status_name status.to_s.titleize end |
#versioned? ⇒ Boolean
68 69 70 |
# File 'app/models/connector.rb', line 68 def versioned? connectable_type.constantize.versioned? end |