Sha256: 39ed5112807d1d57d8e94b6751e23fee5d8beecae9de9853c58852109d923d8b

Contents?: true

Size: 576 Bytes

Versions: 3

Compression:

Stored size: 576 Bytes

Contents

#:enddoc:
module RailsConnector

  class Attribute < CmsBaseModel
    def self.type_of(name)
      attribute = attribute_cache[name.to_s]
      attribute.type if attribute
    end

    def self.reset_cache
      @attribute_cache = nil
    end

    def name
      attribute_name
    end

    def type
      attribute_type.to_sym
    end

    module ClassMethods
      private

      def attribute_cache
        @attribute_cache ||= find(:all).each_with_object({}) do |attr, map|
          map[attr.name] = attr
        end
      end
    end

    extend ClassMethods
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
infopark_cloud_connector-6.8.0.beta.200.663.ceecdee lib/rails_connector/attribute.rb
infopark_cloud_connector-6.8.0.beta.200.650.7c93155 lib/rails_connector/attribute.rb
infopark_cloud_connector-6.8.0.beta.200.621.4c8e1b0 lib/rails_connector/attribute.rb