Sha256: 1adf2304ff8782ab9921f6025de9b1b8b348c823dcfaa07b809e5cffa2c10a5c

Contents?: true

Size: 812 Bytes

Versions: 1

Compression:

Stored size: 812 Bytes

Contents

module Faceted

  module Presenter

    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)
      base.send(:attr_accessor, :success)
    end

    module ClassMethods

      def klass
        @presents
      end

      def presents(name, args={})
        class_name = args[:class_name] || name.to_s.classify
        @presents = 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

1 entries across 1 versions & 1 rubygems

Version Path
faceted-0.7.0 lib/faceted/presenter.rb