Class: SimpleAttribute::Attributes::Image
- Defined in:
- lib/simple_attribute/attributes/image.rb
Instance Attribute Summary
Attributes inherited from Base
#attribute, #options, #record, #value
Instance Method Summary collapse
-
#attribute_name ⇒ Object
Attribute name.
-
#render_attribute ⇒ Object
Render attribute.
-
#render_default_value ⇒ Object
Render default value.
Methods inherited from Base
#default_value, #defaults, #html_options, #initialize, #method_missing, #render, #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_name ⇒ Object
Attribute name
5 6 7 |
# File 'lib/simple_attribute/attributes/image.rb', line 5 def attribute_name 'image' end |
#render_attribute ⇒ Object
Render attribute
25 26 27 |
# File 'lib/simple_attribute/attributes/image.rb', line 25 def render_attribute image_tag value, end |
#render_default_value ⇒ Object
Render default value
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/simple_attribute/attributes/image.rb', line 10 def render_default_value @media_type ||= begin media_type = MiniMime.lookup_by_filename("#{default_value}") media_type.content_type.to_s.split('/').first end if 'image'.in?("#{@media_type}") default_url = asset_url(default_value) image_tag default_url, else super end end |