Sha256: 9d7e5ba14436303cef5b5acbce111939c8d3923163b7ad1df6dc83c78e0855ce

Contents?: true

Size: 720 Bytes

Versions: 2

Compression:

Stored size: 720 Bytes

Contents

module Administrate
  module Page
    class Base
      def initialize(dashboard)
        @dashboard = dashboard
      end

      def resource_name
        @resource_name ||=
          dashboard.class.to_s.scan(/(.+)Dashboard/).first.first.underscore
      end

      protected

      def attribute_field(dashboard, resource, attribute_name, page)
        value = get_attribute_value(resource, attribute_name)

        dashboard.
          attribute_types[attribute_name].
          new(attribute_name, value, page)
      end

      def get_attribute_value(resource, attribute_name)
        resource.public_send(attribute_name)
      rescue NameError
        nil
      end

      attr_reader :dashboard
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
administrate-0.0.11 lib/administrate/page/base.rb
administrate-0.0.10 lib/administrate/page/base.rb