Sha256: 119b4c77e86241d25e4198042eb205ed2a3fdecbf5345a784338b2ca8d2f9373

Contents?: true

Size: 426 Bytes

Versions: 6

Compression:

Stored size: 426 Bytes

Contents

User.class_eval do
  include SocialStream::Oauth2Server::Models::User

  def as_json_with_client options = {}
    hash = as_json_without_client options

    if options[:client] && !options[:client].is_a?(User)
      hash['roles'] = options[:client].contact_to!(self).relations.map{ |r|
        { 
          id: r.id,
          name: r.name
        }
      }
    end

    hash
  end

  alias_method_chain :as_json, :client
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
social_stream-2.1.1 oauth2_server/app/decorators/social_stream/base/user_decorator.rb
social_stream-oauth2_server-2.1.1 app/decorators/social_stream/base/user_decorator.rb
social_stream-2.1.0 oauth2_server/app/decorators/social_stream/base/user_decorator.rb
social_stream-oauth2_server-2.1.0 app/decorators/social_stream/base/user_decorator.rb
social_stream-2.0.4 oauth2_server/app/decorators/social_stream/base/user_decorator.rb
social_stream-oauth2_server-2.0.3 app/decorators/social_stream/base/user_decorator.rb