Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
neoteric-events / app / controllers / neoteric / events_controller.rb
Size: Mime:
module Neoteric
  module EventsController
    def self.included(base)
      base.extend ClassMethods
      base.before_filter :find_upcoming_events,
                         :find_archive_months
    end

    module ClassMethods
      def controls(klass)
        @klass = constantize(klass)
      end

      def klass
        @klass
      end

      private
      def constantize(name)
        name.to_s.split('_').collect(&:capitalize).join.constantize
      end
    end

    def index
      @title = "Events"
      @events = self.class.klass.upcoming
    end

    def show
      @event = self.class.klass.find(params[:id])
    end

    def archive
      @title = "Events in #{Date::MONTHNAMES[params[:month].to_i]} #{params[:year]}"
      @events = self.class.klass.by_month(params[:year], params[:month])
      render :template => 'events/index'
    end

    private
    def find_upcoming_events
      @upcoming_events = self.class.klass.upcoming.limit(5)
    end

    def find_archive_months
      @event_archive_months = self.class.klass.archive_months
    end
  end
end