Class: Cms::Connector
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Cms::Connector
- Includes:
- DefaultAccessible
- Defined in:
- app/models/cms/connector.rb
Instance Method Summary collapse
- #connectable_with_deleted ⇒ Object
- #current_connectable ⇒ Object
- #live? ⇒ Boolean
- #publishable? ⇒ Boolean
-
#should_be_copied? ⇒ Boolean
Determines if a connector should be copied when a page is updated/versioned, etc.
- #status ⇒ Object
- #status_name ⇒ Object
- #versioned? ⇒ Boolean
Instance Method Details
#connectable_with_deleted ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'app/models/cms/connector.rb', line 42 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
34 35 36 37 38 39 40 |
# File 'app/models/cms/connector.rb', line 34 def current_connectable if versioned? connectable.as_of_version(connectable_version) if connectable else get_connectable end end |
#live? ⇒ Boolean
59 60 61 62 63 64 65 |
# File 'app/models/cms/connector.rb', line 59 def live? if publishable? connectable.live? else true end end |
#publishable? ⇒ Boolean
67 68 69 |
# File 'app/models/cms/connector.rb', line 67 def publishable? connectable_type.constantize.publishable? end |
#should_be_copied? ⇒ Boolean
Determines if a connector should be copied when a page is updated/versioned, etc.
78 79 80 81 82 83 84 85 |
# File 'app/models/cms/connector.rb', line 78 def should_be_copied? if connectable && (!connectable.respond_to?(:draft) || !connectable.draft.deleted?) return true end false end |
#status ⇒ Object
51 52 53 |
# File 'app/models/cms/connector.rb', line 51 def status live? ? 'published' : 'draft' end |
#status_name ⇒ Object
55 56 57 |
# File 'app/models/cms/connector.rb', line 55 def status_name status.to_s.titleize end |
#versioned? ⇒ Boolean
71 72 73 |
# File 'app/models/cms/connector.rb', line 71 def versioned? connectable_type.constantize.versioned? end |