Class: ActiveAdminAddons::CustomBuilder
- Inherits:
-
Object
- Object
- ActiveAdminAddons::CustomBuilder
- Defined in:
- lib/activeadmin_addons/support/custom_builder.rb
Direct Known Subclasses
AttachmentBuilder, BoolBuilder, ImageBuilder, ListBuilder, MarkdownBuilder, NumberBuilder, StateBuilder, TagBuilder, ToggleBoolBuilder
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#block ⇒ Object
Returns the value of attribute block.
-
#context ⇒ Object
Returns the value of attribute context.
-
#model ⇒ Object
Returns the value of attribute model.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(context, model, *args, &block) ⇒ CustomBuilder
constructor
A new instance of CustomBuilder.
- #render ⇒ Object
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
#args ⇒ Object
Returns the value of attribute args.
3 4 5 |
# File 'lib/activeadmin_addons/support/custom_builder.rb', line 3 def args @args end |
#block ⇒ Object
Returns the value of attribute block.
3 4 5 |
# File 'lib/activeadmin_addons/support/custom_builder.rb', line 3 def block @block end |
#context ⇒ Object
Returns the value of attribute context.
3 4 5 |
# File 'lib/activeadmin_addons/support/custom_builder.rb', line 3 def context @context end |
#model ⇒ Object
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_name ⇒ Object
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_methods ⇒ Object
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
#render ⇒ Object
12 13 14 |
# File 'lib/activeadmin_addons/support/custom_builder.rb', line 12 def render raise NotImplementedError end |