class CrowdaiAdmin::CustomBuilder
Attributes
args[RW]
block[RW]
context[RW]
model[RW]
Public Class Methods
builder_method_name()
click to toggle source
# File lib/crowdai_admin/custom_builder.rb, line 33 def self.builder_method_name name.underscore.to_s.split("/").last.chomp("_builder") end
create_view_methods()
click to toggle source
# File lib/crowdai_admin/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
new(context, model, *args, &block)
click to toggle source
# File lib/crowdai_admin/custom_builder.rb, line 5 def initialize(context, model, *args, &block) @context = context @model = model @args = *args @block = block end
Public Instance Methods
render()
click to toggle source
# File lib/crowdai_admin/custom_builder.rb, line 12 def render raise NotImplementedError end
Protected Instance Methods
attribute()
click to toggle source
# File lib/crowdai_admin/custom_builder.rb, line 51 def attribute @attribute ||= has_label? ? args[1] : args[0] end
class_name()
click to toggle source
# File lib/crowdai_admin/custom_builder.rb, line 47 def class_name model.class.name.demodulize.underscore end
data()
click to toggle source
# File lib/crowdai_admin/custom_builder.rb, line 39 def data @data ||= block ? block.call(model) : model.send(attribute) end
has_label?()
click to toggle source
# File lib/crowdai_admin/custom_builder.rb, line 55 def has_label? has_opts? ? args.length == 3 : args.length == 2 end
has_opts?()
click to toggle source
# File lib/crowdai_admin/custom_builder.rb, line 59 def has_opts? @has_opts ||= args.last.is_a?(Hash) end
options()
click to toggle source
# File lib/crowdai_admin/custom_builder.rb, line 43 def options @options ||= has_opts? ? args.last : {} end