Class: SimpleAttribute::Attributes::File

Inherits:
Link
  • Object
show all
Defined in:
lib/simple_attribute/attributes/file.rb

Instance Attribute Summary

Attributes inherited from Base

#attribute, #options, #record, #value

Instance Method Summary collapse

Methods inherited from Link

#label_method, #title_method

Methods inherited from Base

#default_value, #defaults, #html_options, #initialize, #label_method, #method_missing, #render, #render_default_value, #render_with_default, #render_wrapper, #renderer_name, #value?, #wrapper, #wrapper?, #wrapper_html

Constructor Details

This class inherits a constructor from SimpleAttribute::Attributes::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class SimpleAttribute::Attributes::Base

Instance Method Details

#attribute_nameObject



4
5
6
# File 'lib/simple_attribute/attributes/file.rb', line 4

def attribute_name
  'file'
end

#render_attributeObject



8
9
10
11
12
13
14
# File 'lib/simple_attribute/attributes/file.rb', line 8

def render_attribute
  file  = value.to_s.split('/').last.split('.').first
  label = file.try(label_method)
  title = file.try(title_method)

  link_to label, value.to_s, html_options.merge(title: title)
end