Sha256: 9eec749900b3b742bfa2b5f30499c391a99c31f556eab114b6883e5bf0a05ff9

Contents?: true

Size: 639 Bytes

Versions: 1

Compression:

Stored size: 639 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 ||= args.last.is_a?(Hash) ? args.last : {}
    end

    def attribute
      @attribute ||= args[1] || args[0]
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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