Sha256: 0dff33f4898af300c97368b5dafb52080bd5f22785e01455993085496fd491ad

Contents?: true

Size: 763 Bytes

Versions: 5

Compression:

Stored size: 763 Bytes

Contents

# Here's an example of how you might use this in rails.

# First, be guarded against changes in third-party libraries
module Awareness
  include Surrounded
  include Casting::Client
  delegate_missing_methods
end

class User
  include Awareness
end

class ApplicationController
  include Awareness
end

class SomeUseCase
  extend Surrounded::Context

  setup(:admin, :other_user, :listener)

  trigger :do_something do
    admin.something
  end

  module Admin
    def something
      puts "Hello, #{other_user}"
      listener.redirect_to('/')
    end
  end
end

class SomethingController < ApplicationController
  def create
    surround(current_user, User.last).do_something
  end

  def surround(admin, other)
    SomeUseCase.new(admin, other, self)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
surrounded-0.5.1 examples/rails.rb
surrounded-0.5.0 examples/rails.rb
surrounded-0.4.1 examples/rails.rb
surrounded-0.4.0 examples/rails.rb
surrounded-0.3.1 examples/rails.rb