Sha256: 5fc627c573decac31c76a38b8b67300d76382a8c811711c29989ad3e2095babe

Contents?: true

Size: 935 Bytes

Versions: 2

Compression:

Stored size: 935 Bytes

Contents

require File.dirname(__FILE__) + '/base_view_spec'
require File.dirname(__FILE__) + '/model_view_spec'
require File.dirname(__FILE__) + '/properties_view_spec'
require File.dirname(__FILE__) + '/custom_view_spec'
require File.dirname(__FILE__) + '/raw_view_spec'


module CouchPotato
  module View
    module CustomViews
      
      def self.included(base)
        base.extend ClassMethods
      end
      
      module ClassMethods
        # Declare a CouchDB view, for examples on how to use see the *ViewSpec classes in CouchPotato::View
        def view(view_name, options)
          self.class.instance_eval do
            define_method view_name do |view_parameters = {}|
              klass = options[:type] ? options[:type].to_s.camelize : 'Model'
              CouchPotato::View.const_get("#{klass}ViewSpec").new self, view_name, options, view_parameters
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
langalex-couch_potato-0.2.3 lib/couch_potato/view/custom_views.rb
langalex-couch_potato-0.2.4 lib/couch_potato/view/custom_views.rb