Class: Semistatic::Part

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/semistatic/part.rb

Instance Method Summary collapse

Instance Method Details

#is_file?Boolean

is this a file?

Returns:

  • (Boolean)


27
28
29
# File 'app/models/semistatic/part.rb', line 27

def is_file?
  is_image? || type == :file
end

#is_image?Boolean

is this is an image?

Returns:

  • (Boolean)


22
23
24
# File 'app/models/semistatic/part.rb', line 22

def is_image?
  type == :image
end

#options=(options) ⇒ Object

force options to be a HashWithIndifferentAccess

Parameters:

  • (nil | Hash | HashWithIndifferentAccess)


38
39
40
41
42
43
# File 'app/models/semistatic/part.rb', line 38

def options=(options)
  if options.respond_to? :deep_symbolize_keys
    options = options.deep_symbolize_keys
  end
  write_attribute(:options, options)
end

#typeObject

Returns Symbol.

Returns:

  • Symbol



32
33
34
# File 'app/models/semistatic/part.rb', line 32

def type
  options[:type].to_sym if options[:type]
end

#valid_content_typeObject



46
47
48
49
50
51
52
# File 'app/models/semistatic/part.rb', line 46

def valid_content_type
  if is_image?
     ['image/jpg', 'image/png', 'image/gif']
  else
    []
  end
end