Sha256: ab5909659bf2be58954ff730d323584910ac48898c6c500163f1f5f8cab7b442

Contents?: true

Size: 761 Bytes

Versions: 32

Compression:

Stored size: 761 Bytes

Contents

module Faceted

  module Interface

    include Faceted::HasObject

    # Class methods ===========================================================

    def self.included(base)
      base.extend ActiveModel::Naming
      base.extend ClassMethods
      base.extend Faceted::Model::ModelClassMethods
      base.send(:attr_accessor, :id)
      base.send(:attr_accessor, :errors)
    end

    module ClassMethods

      def klass
        @wraps
      end

      def wraps(name, args={})
        class_name = args[:class_name] || name.to_s.classify
        @wraps = eval(class_name)
        define_method :"#{class_name.downcase}" do
          object
        end
      end

      def where(args)
        materialize(klass.where(args))
      end

    end

  end

end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
faceted-1.6.2 lib/faceted/interface.rb
faceted-1.6.1 lib/faceted/interface.rb
faceted-1.6.0 lib/faceted/interface.rb
faceted-1.5.1 lib/faceted/interface.rb
faceted-1.5.0 lib/faceted/interface.rb
faceted-1.4.0 lib/faceted/interface.rb
faceted-1.3.3 lib/faceted/interface.rb
faceted-1.3.2 lib/faceted/interface.rb
faceted-1.3.1 lib/faceted/interface.rb
faceted-1.3.0 lib/faceted/interface.rb
faceted-1.2.3 lib/faceted/interface.rb
faceted-1.2.2 lib/faceted/interface.rb
faceted-1.2.1 lib/faceted/interface.rb
faceted-1.2.0 lib/faceted/interface.rb
faceted-1.1.1 lib/faceted/interface.rb
faceted-1.1.0 lib/faceted/interface.rb
faceted-1.0.8 lib/faceted/interface.rb
faceted-1.0.7 lib/faceted/interface.rb
faceted-1.0.6 lib/faceted/interface.rb
faceted-1.0.5 lib/faceted/interface.rb