Class: Tramway::Configs::Entity
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Tramway::Configs::Entity
show all
- Defined in:
- lib/tramway/configs/entity.rb
Overview
Tramway is an entity-based framework
Defined Under Namespace
Classes: HumanNameStruct, RouteStruct
Constant Summary
collapse
- ACTIONS =
Route Struct contains implemented in Tramway CRUD and helpful routes for the entity
%i[index show new create].freeze
Instance Method Summary
collapse
Instance Method Details
#create_helper_method ⇒ Object
54
55
56
|
# File 'lib/tramway/configs/entity.rb', line 54
def create_helper_method
build_helper_method(name, route:, namespace:, plural: true)
end
|
#human_name ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/tramway/configs/entity.rb', line 26
def human_name
if model_class.present?
model_name = model_class.model_name.human
[model_name, pluralized(model_name)]
else
[name.capitalize, name.pluralize.capitalize]
end => single, plural
HumanNameStruct.new(single, plural)
end
|
#index_helper_method ⇒ Object
46
47
48
|
# File 'lib/tramway/configs/entity.rb', line 46
def index_helper_method
build_helper_method(name, route:, namespace:, plural: true)
end
|
#new_helper_method ⇒ Object
50
51
52
|
# File 'lib/tramway/configs/entity.rb', line 50
def new_helper_method
build_helper_method(name, route:, namespace:, plural: false, action: :new)
end
|
#page(name) ⇒ Object
Also known as:
set_page?
38
39
40
|
# File 'lib/tramway/configs/entity.rb', line 38
def page(name)
pages.find { |page| page.action == name.to_s }
end
|
#routes ⇒ Object
22
23
24
|
# File 'lib/tramway/configs/entity.rb', line 22
def routes
RouteStruct.new(*route_helper_methods)
end
|
#show_helper_method ⇒ Object
42
43
44
|
# File 'lib/tramway/configs/entity.rb', line 42
def show_helper_method
build_helper_method(name, route:, namespace:, plural: false)
end
|