Module: Tramway::Core::Concerns::AttributesDecoratorHelper

Included in:
ApplicationDecorator
Defined in:
app/decorators/tramway/core/concerns/attributes_decorator_helper.rb

Constant Summary collapse

BASE64_REGEXP =
%r{^(?:[a-zA-Z0-9+/]{4})*(?:|(?:[a-zA-Z0-9+/]{3}=)|
(?:[a-zA-Z0-9+/]{2}==)|(?:[a-zA-Z0-9+/]{1}===))$}x.freeze

Instance Method Summary collapse

Instance Method Details

#date_view(value) ⇒ Object



4
5
6
# File 'app/decorators/tramway/core/concerns/attributes_decorator_helper.rb', line 4

def date_view(value)
  I18n.l value.to_date if value
end

#datetime_view(value) ⇒ Object



8
9
10
# File 'app/decorators/tramway/core/concerns/attributes_decorator_helper.rb', line 8

def datetime_view(value)
  I18n.l value if value
end

#enumerize_view(value) ⇒ Object



28
29
30
# File 'app/decorators/tramway/core/concerns/attributes_decorator_helper.rb', line 28

def enumerize_view(value)
  value.text
end

#image_view(original, thumb: nil, filename: nil) ⇒ Object



19
20
21
22
23
24
25
26
# File 'app/decorators/tramway/core/concerns/attributes_decorator_helper.rb', line 19

def image_view(original, thumb: nil, filename: nil)
  return unless original.present?

  filename ||= build_filename(original)
  (:div) do
    build_div_content src_original(original), src_thumb(original, thumb), filename || build_filename(original)
  end
end

#state_machine_view(object, attribute_name) ⇒ Object



12
13
14
# File 'app/decorators/tramway/core/concerns/attributes_decorator_helper.rb', line 12

def state_machine_view(object, attribute_name)
  object.send "human_#{attribute_name}_name"
end