Class: AdminIt::SingleContext
- Inherits:
-
Context
- Object
- Context
- AdminIt::SingleContext
show all
- Defined in:
- lib/admin_it/context/single_context.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#entity ⇒ Object
Returns the value of attribute entity.
110
111
112
|
# File 'lib/admin_it/context/single_context.rb', line 110
def entity
@entity
end
|
Class Method Details
.path(entity) ⇒ Object
101
102
103
104
105
106
|
# File 'lib/admin_it/context/single_context.rb', line 101
def self.path(entity)
AdminIt::Engine.routes.url_helpers.send(
"#{resource.name}_path",
entity
)
end
|
.sections ⇒ Object
def self.before_configure()
@show_resource_link = true
end
93
94
95
|
# File 'lib/admin_it/context/single_context.rb', line 93
def self.sections
(@sections ||= {}).values
end
|
.single? ⇒ Boolean
97
98
99
|
# File 'lib/admin_it/context/single_context.rb', line 97
def self.single?
true
end
|
Instance Method Details
#path(_entity: nil) ⇒ Object
125
126
127
128
|
# File 'lib/admin_it/context/single_context.rb', line 125
def path(_entity: nil)
_entity ||= entity
self.class.path(_entity)
end
|
#section ⇒ Object
130
131
132
|
# File 'lib/admin_it/context/single_context.rb', line 130
def section
@section ||= sections.empty? ? :none : :general
end
|
#section=(value) ⇒ Object
134
135
136
137
138
139
140
141
142
|
# File 'lib/admin_it/context/single_context.rb', line 134
def section=(value)
value = value.ensure_symbol(downcase: true) || return
@section = value
end
|
#url_params(**params) ⇒ Object
144
145
146
147
|
# File 'lib/admin_it/context/single_context.rb', line 144
def url_params(**params)
params[:section] = section unless params.key?(:section)
super(**params)
end
|
#values ⇒ Object
120
121
122
123
|
# File 'lib/admin_it/context/single_context.rb', line 120
def values
return {} if @entity.nil?
Hash[fields(scope: :readable).map { |f| [f.name, f.read(@entity)] }]
end
|