Sha256: cdd271e271d5d41b94fc0a025c5c50f684cc75f40b56f0b5336e404b63444fdf

Contents?: true

Size: 998 Bytes

Versions: 23

Compression:

Stored size: 998 Bytes

Contents

module EventPresenter
  module ClassMethods
    # Presents events for a select tag in the views
    def options_for_select_by_organization(organization)
      where(organization_id: organization.id).collect do |event|
        [event.name, event.id]
      end.sort{|a, b| a[0] <=> b[0]}
    end
  end

  module InstanceMethods
    def to_s
      self.name || ""
    end

    ### JSON Methods
    def as_widget_json(options = {})
      as_json(options.merge(:methods => ['shows', 'charts', 'venue'])).merge('performances' => upcoming_public_shows.as_json)
    end

    def as_full_calendar_json
      shows.collect do |p|
        { :title  => '',
          :start  => p.datetime_local_to_event,
          :allDay => false,
          :color  => '#077083',
          :id     => p.id
        }
      end
    end

    def as_json(options = {})
      super(options)
    end
  end

  def self.included(receiver)
    receiver.extend         ClassMethods
    receiver.send :include, InstanceMethods
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
artfully_ose-1.2.0.pre.21 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.20 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.19 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.18 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.17 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.16 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.15 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.12 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.11 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.10 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.9 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.8 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.7 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.6 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.5 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.4 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.3 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.2 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre.1 app/presenters/event_presenter.rb
artfully_ose-1.2.0.pre app/presenters/event_presenter.rb