Sha256: e43d2f6257ec51c2d5f903c48531c442a6b98f319169351a11e8d33ac5d0d79b

Contents?: true

Size: 992 Bytes

Versions: 23

Compression:

Stored size: 992 Bytes

Contents

module ActiveAdminAddons
  class CustomBuilder
    attr_accessor :context, :model, :args, :block

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

    def render
    end

    def self.render(context, model, *args, &block)
      new(context, model, *args, &block).render
    end

    protected

    def data
      @data ||= block ? block.call(model) : model.send(attribute)
    end

    def options
      @options ||= has_opts? ? args.last : {}
    end

    # attachment_column :foto
    # attachment_column :foto, style: :hola
    # attachment_column "Mi Foto", :foto
    # attachment_column "Mi Foto", :foto, {}
    # attachment_column :foto do
    # end
    def attribute
      @attribute ||= has_label? ? args[1] : args[0]
    end

    def has_label?
      has_opts? ? args.length == 3 : args.length == 2
    end

    def has_opts?
      @has_opts ||= args.last.is_a?(Hash)
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
activeadmin_addons-0.12.0 lib/activeadmin_addons/support/custom_builder.rb
activeadmin_addons-0.11.0 lib/activeadmin_addons/support/custom_builder.rb
activeadmin_addons-0.10.1 lib/activeadmin_addons/support/custom_builder.rb
activeadmin_addons-0.10.0 lib/activeadmin_addons/support/custom_builder.rb
activeadmin_addons-0.9.3 lib/activeadmin_addons/support/custom_builder.rb
activeadmin_addons-0.9.2 lib/activeadmin_addons/support/custom_builder.rb
activeadmin_addons-0.9.1 lib/activeadmin_addons/support/custom_builder.rb
activeadmin_addons-0.9.0 lib/activeadmin_addons/support/custom_builder.rb
activeadmin_addons-0.8.0 lib/activeadmin_addons/support/custom_builder.rb
activeadmin_addons-0.7.0 lib/activeadmin_addons/support/custom_builder.rb
activeadmin_addons-0.6.4 lib/activeadmin_addons/support/custom_builder.rb
activeadmin_addons-0.6.3 lib/activeadmin_addons/support/custom_builder.rb
activeadmin_addons-0.6.2 lib/activeadmin_addons/support/custom_builder.rb
activeadmin_addons-0.6.1 lib/activeadmin_addons/support/custom_builder.rb
activeadmin_addons-0.6.0 lib/activeadmin_addons/support/custom_builder.rb
activeadmin_addons-0.5.0 lib/activeadmin_addons/support/custom_builder.rb
activeadmin_addons-0.4.0 lib/activeadmin_addons/support/custom_builder.rb
activeadmin_addons-0.3.4 lib/activeadmin_addons/support/custom_builder.rb
activeadmin_addons-0.3.3 lib/activeadmin_addons/support/custom_builder.rb
activeadmin_addons-0.3.2 lib/activeadmin_addons/support/custom_builder.rb