Class: AtomicAdmin::Interaction::Resource
- Defined in:
- lib/atomic_admin/interaction/resource.rb
Instance Attribute Summary
Attributes inherited from Base
#data, #icon, #key, #order, #title, #type
Instance Method Summary collapse
-
#initialize(controller:, table:, actions: [], plural:, singular:, **kwargs) ⇒ Resource
constructor
A new instance of Resource.
- #resolve(**kwargs) ⇒ Object
Constructor Details
#initialize(controller:, table:, actions: [], plural:, singular:, **kwargs) ⇒ Resource
Returns a new instance of Resource.
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/atomic_admin/interaction/resource.rb', line 4 def initialize(controller:, table:, actions: [], plural:, singular:, **kwargs) super(**kwargs) @controller = controller @table = table @actions = actions @plural = plural @singular = singular Rails.application.config.to_prepare do controller_name = controller.demodulize AtomicAdmin::Api::Admin::V1.const_set(controller_name, controller.constantize) end end |
Instance Method Details
#resolve(**kwargs) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/atomic_admin/interaction/resource.rb', line 18 def resolve(**kwargs) hash = super(**kwargs) hash[:plural] = @plural hash[:singular] = @singular hash[:table] = @table hash[:actions] = @actions.map do |action| action_hash = { type: action[:type], label: action[:label], } if action[:schema] schema_factory = action[:schema] schema = schema_factory.new(**kwargs) action_hash[:schema] = schema.schema action_hash[:uischema] = schema.uischema end action_hash end hash end |