Class: Adminable::Presenters::Entry
- Inherits:
-
Base
- Object
- Base
- Adminable::Presenters::Entry
show all
- Defined in:
- lib/adminable/presenters/entry.rb
Instance Method Summary
collapse
Constructor Details
#initialize(entry) ⇒ Entry
Returns a new instance of Entry.
4
5
6
|
# File 'lib/adminable/presenters/entry.rb', line 4
def initialize(entry)
@entry = entry
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
60
61
62
|
# File 'lib/adminable/presenters/entry.rb', line 60
def method_missing(method_name, *args, &block)
entry.public_send(method_name, *args, &block)
end
|
Instance Method Details
#link_to_delete ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/adminable/presenters/entry.rb', line 28
def link_to_delete
view.link_to(
I18n.t('adminable.buttons.delete'),
polymorphic_path(@entry),
class: 'btn btn-danger-outline pull-xs-right',
method: :delete,
data: {
confirm: I18n.t('adminable.ui.confirm')
}
)
end
|
#link_to_delete_small ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/adminable/presenters/entry.rb', line 48
def link_to_delete_small
view.link_to(
I18n.t('adminable.buttons.delete'),
polymorphic_path(entry),
class: 'label label-danger',
method: :delete,
data: {
confirm: I18n.t('adminable.ui.confirm')
}
)
end
|
#link_to_edit_small ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/adminable/presenters/entry.rb', line 40
def link_to_edit_small
view.link_to(
I18n.t('adminable.buttons.edit'),
edit_polymorphic_path(entry),
class: 'label label-primary'
)
end
|
#link_to_self ⇒ Object
18
19
20
21
22
23
24
25
26
|
# File 'lib/adminable/presenters/entry.rb', line 18
def link_to_self
return to_name unless resource
view.link_to(
to_name,
edit_polymorphic_path(entry),
target: '_blank'
)
end
|
#respond_to_missing?(method_name) ⇒ Boolean
64
65
66
|
# File 'lib/adminable/presenters/entry.rb', line 64
def respond_to_missing?(method_name, *)
entry.respond_to?(method_name)
end
|
#to_name ⇒ Object
8
9
10
11
12
13
14
15
16
|
# File 'lib/adminable/presenters/entry.rb', line 8
def to_name
%i(name title email login id).each do |method_name|
begin
return entry.public_send(method_name)
rescue NoMethodError
next
end
end
end
|