Class: Pageflow::UsedFile

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
app/models/pageflow/used_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(file, usage = nil) ⇒ UsedFile

Returns a new instance of UsedFile.



3
4
5
6
7
# File 'app/models/pageflow/used_file.rb', line 3

def initialize(file, usage = nil)
  super(file)
  @file = file
  @usage = usage || file.usages.first
end

Instance Method Details

#classObject



33
34
35
# File 'app/models/pageflow/used_file.rb', line 33

def class
  @file.class
end

#configurationObject



9
10
11
# File 'app/models/pageflow/used_file.rb', line 9

def configuration
  @usage.configuration
end

#is_a?(klass) ⇒ Boolean

Not delegated by default. Required to allow using instances in Active Record conditions.

Returns:

  • (Boolean)


29
30
31
# File 'app/models/pageflow/used_file.rb', line 29

def is_a?(klass)
  @file.is_a?(klass)
end

#perma_idObject



22
23
24
# File 'app/models/pageflow/used_file.rb', line 22

def perma_id
  @usage.perma_id
end

#update_attributes!(attributes) ⇒ Object



13
14
15
16
# File 'app/models/pageflow/used_file.rb', line 13

def update_attributes!(attributes)
  super(attributes.except(:configuration))
  @usage.update_attributes!(attributes.slice(:configuration))
end

#usage_idObject



18
19
20
# File 'app/models/pageflow/used_file.rb', line 18

def usage_id
  @usage.id
end