Sha256: 5987fe457b1c67820e2e078d9d5a5b35fa23fc4c51d857fee1f1ccd947002178

Contents?: true

Size: 702 Bytes

Versions: 1

Compression:

Stored size: 702 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

    def attribute
      @attribute ||= has_opts? ? args[0] : args[1]
    end

    def has_opts?
      args[1] && args[1].is_a?(Hash)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activeadmin_addons-0.2.3 lib/activeadmin_addons/support/custom_builder.rb