Sha256: 82370c3609043c2cc92737c717145d81e486eeba5cb0691d97aa56b4d5d6f6d0

Contents?: true

Size: 700 Bytes

Versions: 3

Compression:

Stored size: 700 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
    SomeUseCase.new(current_user, User.last, self).do_something
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
surrounded-0.3.0 examples/rails.rb
surrounded-0.2.1 examples/rails.rb
surrounded-0.2.0 examples/rails.rb