Class: ActiveElement::ControllerState

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#authenticatorObject

Returns the value of attribute authenticator.



10
11
12
# File 'lib/active_element/controller_state.rb', line 10

def authenticator
  @authenticator
end

#authorizorObject

Returns the value of attribute authorizor.



10
11
12
# File 'lib/active_element/controller_state.rb', line 10

def authorizor
  @authorizor
end

#deletableObject

Returns the value of attribute deletable.



10
11
12
# File 'lib/active_element/controller_state.rb', line 10

def deletable
  @deletable
end

#editable_fieldsObject (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_optionsObject (readonly)

Returns the value of attribute field_options.



8
9
10
# File 'lib/active_element/controller_state.rb', line 8

def field_options
  @field_options
end

#list_orderObject

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_scopeObject

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_fieldsObject (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

#modelObject

Returns the value of attribute model.



10
11
12
# File 'lib/active_element/controller_state.rb', line 10

def model
  @model
end

#permissionsObject (readonly)

Returns the value of attribute permissions.



8
9
10
# File 'lib/active_element/controller_state.rb', line 8

def permissions
  @permissions
end

#search_requiredObject

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_fieldsObject (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_inObject

Returns the value of attribute sign_in.



10
11
12
# File 'lib/active_element/controller_state.rb', line 10

def 
  @sign_in
end

#sign_in_methodObject

Returns the value of attribute sign_in_method.



10
11
12
# File 'lib/active_element/controller_state.rb', line 10

def 
  @sign_in_method
end

#sign_in_pathObject

Returns the value of attribute sign_in_path.



10
11
12
# File 'lib/active_element/controller_state.rb', line 10

def 
  @sign_in_path
end

#sign_out_methodObject

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_pathObject

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_fieldsObject (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

Returns:

  • (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

Returns:

  • (Boolean)


27
28
29
# File 'lib/active_element/controller_state.rb', line 27

def deletable?
  !!deletable
end

#editable?Boolean

Returns:

  • (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

Returns:

  • (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