Class: ActiveElement::ControllerState
- Inherits:
-
Object
- Object
- ActiveElement::ControllerState
- Defined in:
- lib/active_element/controller_state.rb
Overview
Stores various data for a controller, including various field definitions and authentication configuration. Used throughout ActiveElement for generating dynamic content based on controller configuration.
Instance Attribute Summary collapse
-
#authenticator ⇒ Object
Returns the value of attribute authenticator.
-
#authorizor ⇒ Object
Returns the value of attribute authorizor.
-
#deletable ⇒ Object
Returns the value of attribute deletable.
-
#editable_fields ⇒ Object
readonly
Returns the value of attribute editable_fields.
-
#field_options ⇒ Object
readonly
Returns the value of attribute field_options.
-
#list_order ⇒ Object
Returns the value of attribute list_order.
-
#list_scope ⇒ Object
Returns the value of attribute list_scope.
-
#listable_fields ⇒ Object
readonly
Returns the value of attribute listable_fields.
-
#model ⇒ Object
Returns the value of attribute model.
-
#permissions ⇒ Object
readonly
Returns the value of attribute permissions.
-
#search_required ⇒ Object
Returns the value of attribute search_required.
-
#searchable_fields ⇒ Object
readonly
Returns the value of attribute searchable_fields.
-
#sign_in ⇒ Object
Returns the value of attribute sign_in.
-
#sign_in_method ⇒ Object
Returns the value of attribute sign_in_method.
-
#sign_in_path ⇒ Object
Returns the value of attribute sign_in_path.
-
#sign_out_method ⇒ Object
Returns the value of attribute sign_out_method.
-
#sign_out_path ⇒ Object
Returns the value of attribute sign_out_path.
-
#viewable_fields ⇒ Object
readonly
Returns the value of attribute viewable_fields.
Instance Method Summary collapse
- #creatable? ⇒ Boolean
- #deletable? ⇒ Boolean
- #editable? ⇒ Boolean
-
#initialize(controller:) ⇒ ControllerState
constructor
A new instance of ControllerState.
- #viewable? ⇒ Boolean
Constructor Details
#initialize(controller:) ⇒ ControllerState
Returns a new instance of ControllerState.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/active_element/controller_state.rb', line 13 def initialize(controller:) @controller = controller @permissions = [] @authenticator = nil @authorizor = nil @deletable = false @listable_fields = [] @viewable_fields = [] @editable_fields = [] @searchable_fields = [] @field_options = {} @model = nil end |
Instance Attribute Details
#authenticator ⇒ Object
Returns the value of attribute authenticator.
10 11 12 |
# File 'lib/active_element/controller_state.rb', line 10 def authenticator @authenticator end |
#authorizor ⇒ Object
Returns the value of attribute authorizor.
10 11 12 |
# File 'lib/active_element/controller_state.rb', line 10 def @authorizor end |
#deletable ⇒ Object
Returns the value of attribute deletable.
10 11 12 |
# File 'lib/active_element/controller_state.rb', line 10 def deletable @deletable end |
#editable_fields ⇒ Object (readonly)
Returns the value of attribute editable_fields.
8 9 10 |
# File 'lib/active_element/controller_state.rb', line 8 def editable_fields @editable_fields end |
#field_options ⇒ Object (readonly)
Returns the value of attribute field_options.
8 9 10 |
# File 'lib/active_element/controller_state.rb', line 8 def @field_options end |
#list_order ⇒ Object
Returns the value of attribute list_order.
10 11 12 |
# File 'lib/active_element/controller_state.rb', line 10 def list_order @list_order end |
#list_scope ⇒ Object
Returns the value of attribute list_scope.
10 11 12 |
# File 'lib/active_element/controller_state.rb', line 10 def list_scope @list_scope end |
#listable_fields ⇒ Object (readonly)
Returns the value of attribute listable_fields.
8 9 10 |
# File 'lib/active_element/controller_state.rb', line 8 def listable_fields @listable_fields end |
#model ⇒ Object
Returns the value of attribute model.
10 11 12 |
# File 'lib/active_element/controller_state.rb', line 10 def model @model end |
#permissions ⇒ Object (readonly)
Returns the value of attribute permissions.
8 9 10 |
# File 'lib/active_element/controller_state.rb', line 8 def @permissions end |
#search_required ⇒ Object
Returns the value of attribute search_required.
10 11 12 |
# File 'lib/active_element/controller_state.rb', line 10 def search_required @search_required end |
#searchable_fields ⇒ Object (readonly)
Returns the value of attribute searchable_fields.
8 9 10 |
# File 'lib/active_element/controller_state.rb', line 8 def searchable_fields @searchable_fields end |
#sign_in ⇒ Object
Returns the value of attribute sign_in.
10 11 12 |
# File 'lib/active_element/controller_state.rb', line 10 def sign_in @sign_in end |
#sign_in_method ⇒ Object
Returns the value of attribute sign_in_method.
10 11 12 |
# File 'lib/active_element/controller_state.rb', line 10 def sign_in_method @sign_in_method end |
#sign_in_path ⇒ Object
Returns the value of attribute sign_in_path.
10 11 12 |
# File 'lib/active_element/controller_state.rb', line 10 def sign_in_path @sign_in_path end |
#sign_out_method ⇒ Object
Returns the value of attribute sign_out_method.
10 11 12 |
# File 'lib/active_element/controller_state.rb', line 10 def sign_out_method @sign_out_method end |
#sign_out_path ⇒ Object
Returns the value of attribute sign_out_path.
10 11 12 |
# File 'lib/active_element/controller_state.rb', line 10 def sign_out_path @sign_out_path end |
#viewable_fields ⇒ Object (readonly)
Returns the value of attribute viewable_fields.
8 9 10 |
# File 'lib/active_element/controller_state.rb', line 8 def viewable_fields @viewable_fields end |
Instance Method Details
#creatable? ⇒ Boolean
39 40 41 |
# File 'lib/active_element/controller_state.rb', line 39 def creatable? editable_fields.present? || controller.public_methods(false).include?(:new) end |
#deletable? ⇒ Boolean
27 28 29 |
# File 'lib/active_element/controller_state.rb', line 27 def deletable? !!deletable end |
#editable? ⇒ Boolean
35 36 37 |
# File 'lib/active_element/controller_state.rb', line 35 def editable? editable_fields.present? || controller.public_methods(false).include?(:edit) end |
#viewable? ⇒ Boolean
31 32 33 |
# File 'lib/active_element/controller_state.rb', line 31 def viewable? viewable_fields.present? || controller.public_methods(false).include?(:show) end |