Class: ActiveAdminAddons::CustomBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/activeadmin_addons/support/custom_builder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, model, *args, &block) ⇒ CustomBuilder

Returns a new instance of CustomBuilder.



5
6
7
8
9
10
# File 'lib/activeadmin_addons/support/custom_builder.rb', line 5

def initialize(context, model, *args, &block)
  @context = context
  @model = model
  @args = *args
  @block = block
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



3
4
5
# File 'lib/activeadmin_addons/support/custom_builder.rb', line 3

def args
  @args
end

#blockObject

Returns the value of attribute block.



3
4
5
# File 'lib/activeadmin_addons/support/custom_builder.rb', line 3

def block
  @block
end

#contextObject

Returns the value of attribute context.



3
4
5
# File 'lib/activeadmin_addons/support/custom_builder.rb', line 3

def context
  @context
end

#modelObject

Returns the value of attribute model.



3
4
5
# File 'lib/activeadmin_addons/support/custom_builder.rb', line 3

def model
  @model
end

Class Method Details

.builder_method_nameObject



33
34
35
# File 'lib/activeadmin_addons/support/custom_builder.rb', line 33

def self.builder_method_name
  name.underscore.to_s.split("/").last.chomp("_builder")
end

.create_view_methodsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/activeadmin_addons/support/custom_builder.rb', line 16

def self.create_view_methods
  builder_class = self
  builder_name = builder_method_name

  ::ActiveAdmin::Views::TableFor.class_eval do
    define_method("#{builder_name}_column") do |*args, &block|
      column(*args) { |model| builder_class.new(self, model, *args, &block).render }
    end
  end

  ::ActiveAdmin::Views::AttributesTable.class_eval do
    define_method("#{builder_name}_row") do |*args, &block|
      row(*args) { |model| builder_class.new(self, model, *args, &block).render }
    end
  end
end

Instance Method Details

#renderObject

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/activeadmin_addons/support/custom_builder.rb', line 12

def render
  raise NotImplementedError
end