Class: Cms::Connector

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

Instance Method Summary collapse

Instance Method Details

#connectable_with_deletedObject


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_connectableObject


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

Returns:

  • (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

Returns:

  • (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.

Returns:

  • (Boolean)

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

#statusObject


51
52
53
# File 'app/models/cms/connector.rb', line 51

def status
  live? ? 'published' : 'draft'
end

#status_nameObject


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

def status_name
  status.to_s.titleize
end

#versioned?Boolean

Returns:

  • (Boolean)

71
72
73
# File 'app/models/cms/connector.rb', line 71

def versioned?
  connectable_type.constantize.versioned?
end