Class: Workarea::Content::Asset

Inherits:
Object
  • Object
show all
Extended by:
Dragonfly::Model
Includes:
Mongoid::Document::Taggable, ApplicationDocument, Workarea::Commentable
Defined in:
app/models/workarea/content/asset.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Workarea::Commentable

#add_subscription, #remove_subscription

Methods included from Mongoid::Document::Taggable

included

Methods included from ApplicationDocument

#releasable?

Methods included from Sidekiq::Callbacks

add_worker, assert_valid_config!, async, caching_classes?, disable, enable, inline, #run_callbacks, workers, workers_list

Methods included from Mongoid::Document

#embedded_children

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



116
117
118
119
120
121
122
# File 'app/models/workarea/content/asset.rb', line 116

def method_missing(sym, *args, &block)
  if file.respond_to?(sym)
    file.send(sym, *args, &block)
  else
    super
  end
end

Class Method Details

.favicon_placeholderObject



71
72
73
74
75
76
77
78
79
80
# File 'app/models/workarea/content/asset.rb', line 71

def self.favicon_placeholder
  find_by(file_name: Workarea.config.favicon_placeholder_image_name)

rescue Mongoid::Errors::DocumentNotFound
  create!(
    file: FindPipelineAsset.new(
      Workarea.config.favicon_placeholder_image_name
    ).path
  )
end

.favicons(type = nil) ⇒ Object



82
83
84
# File 'app/models/workarea/content/asset.rb', line 82

def self.favicons(type = nil)
  tagged_with(['favicon', type].compact.join('-'))
end

.image_placeholderObject



49
50
51
52
53
54
55
56
57
58
# File 'app/models/workarea/content/asset.rb', line 49

def self.image_placeholder
  find_by(file_name: Workarea.config.image_placeholder_image_name)

rescue Mongoid::Errors::DocumentNotFound
  create!(
    file: FindPipelineAsset.new(
      Workarea.config.image_placeholder_image_name
    ).path
  )
end

.open_graph_defaultObject



86
87
88
# File 'app/models/workarea/content/asset.rb', line 86

def self.open_graph_default
  tagged_with('og-default').first
end

.open_graph_placeholderObject



60
61
62
63
64
65
66
67
68
69
# File 'app/models/workarea/content/asset.rb', line 60

def self.open_graph_placeholder
  find_by(file_name: Workarea.config.open_graph_placeholder_image_name)

rescue Mongoid::Errors::DocumentNotFound
  create!(
    file: FindPipelineAsset.new(
      Workarea.config.open_graph_placeholder_image_name
    ).path
  )
end

Instance Method Details

#favicon?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'app/models/workarea/content/asset.rb', line 90

def favicon?
  tags.any? { |t| t.starts_with?('favicon') }
end

#favicon_placeholder?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'app/models/workarea/content/asset.rb', line 102

def favicon_placeholder?
  file_name == Workarea.config.favicon_placeholder_image_name
end

#image_placeholder?Boolean

Returns:

  • (Boolean)


94
95
96
# File 'app/models/workarea/content/asset.rb', line 94

def image_placeholder?
  file_name == Workarea.config.image_placeholder_image_name
end

#open_graph_placeholder?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'app/models/workarea/content/asset.rb', line 98

def open_graph_placeholder?
  file_name == Workarea.config.open_graph_placeholder_image_name
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


112
113
114
# File 'app/models/workarea/content/asset.rb', line 112

def respond_to_missing?(method_name, include_private = false)
  super || file.respond_to?(method_name)
end