Sha256: 20fcbf797943cd7b77923b88334270cbbb2fc02ff4d48a3f8f13a55740277168

Contents?: true

Size: 980 Bytes

Versions: 12

Compression:

Stored size: 980 Bytes

Contents

module BootstrapAdmin

  # BootstrapAdmin::Attribute represents a model attribute and stores
  # its name, human_name and a computed "type" which can be one of:
  #  :association
  #  :attribute
  #  :none
  # (take a look at active_record_extensions).
  #
  # This is used to build UI elements, see:
  #   app/views/defaults/show
  #   app/views/defaults/form
  #   app/views/defaults/index

  class Attribute
    attr_reader :name, :human_name, :type

    def initialize name, human_name, type
      @name, @human_name, @type = name, human_name, type
    end

    # @return [String] the attribute's name
    def to_s; name.to_s; end

    # @return [Symbol] the attribute's name, but as a Symbol
    def to_sym; to_s.to_sym; end

    # @return [true, false] true if type is :association, false otherwise
    def association?; :association == type; end

    # @return [true, false] true if type is :attribute, false otherwise
    def attribute?; :attribute == type; end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
bootstrap_admin-1.0.1 lib/bootstrap_admin/attribute.rb
bootstrap_admin-1.0.0 lib/bootstrap_admin/attribute.rb
bootstrap_admin-0.0.18 lib/bootstrap_admin/attribute.rb
bootstrap_admin-0.0.17 lib/bootstrap_admin/attribute.rb
bootstrap_admin-0.0.15 lib/bootstrap_admin/attribute.rb
bootstrap_admin-0.0.14 lib/bootstrap_admin/attribute.rb
bootstrap_admin-0.0.13 lib/bootstrap_admin/attribute.rb
bootstrap_admin-0.0.12 lib/bootstrap_admin/attribute.rb
bootstrap_admin-0.0.11 lib/bootstrap_admin/attribute.rb
bootstrap_admin-0.0.10 lib/bootstrap_admin/attribute.rb
bootstrap_admin-0.0.9 lib/bootstrap_admin/attribute.rb
bootstrap_admin-0.0.8 lib/bootstrap_admin/attribute.rb