Class: Tramway::UserDecorator

Inherits:
ApplicationDecorator show all
Defined in:
app/decorators/tramway/user_decorator.rb

Constant Summary

Constants inherited from ApplicationDecorator

ApplicationDecorator::RESERVED_WORDS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationDecorator

#additional_buttons, #associations, #attributes, decorate, #initialize, #link, #listed_state_machines, #model, model_class, model_name, #present?, #public_path, #render

Methods included from ClassNameHelpers

#decorator_class_name, #form_class_name, #model_class_name

Methods included from CopyToClipboardHelper

#copy_to_clipboard

Constructor Details

This class inherits a constructor from Tramway::ApplicationDecorator

Class Method Details

.collectionsObject



5
6
7
# File 'app/decorators/tramway/user_decorator.rb', line 5

def collections
  [:all]
end

.list_attributesObject



9
10
11
# File 'app/decorators/tramway/user_decorator.rb', line 9

def list_attributes
  [:email]
end

.show_attributesObject



13
14
15
# File 'app/decorators/tramway/user_decorator.rb', line 13

def show_attributes
  %i[email first_name last_name phone role created_at updated_at credential_text]
end

Instance Method Details

#credential_textObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/decorators/tramway/user_decorator.rb', line 32

def credential_text
  (:pre) do
    id = "credential_text_#{object.id}"

    concat((:span, id: id) do
      text = "URL: #{ENV['PROJECT_URL']}\n"
      text += "Email: #{object.email}\n"
      "#{text}Password: "
    end)

    concat((:br))

    concat copy_to_clipboard id
  end
end

#nameObject Also known as: title



28
29
30
# File 'app/decorators/tramway/user_decorator.rb', line 28

def name
  "#{object&.first_name} #{object&.last_name}"
end

#show_associationsObject



18
19
20
# File 'app/decorators/tramway/user_decorator.rb', line 18

def show_associations
  [:social_networks]
end