Sha256: 5626c452439dad43536139db76734d21a3dc72e742be10d877ea1523fb0b4f9e

Contents?: true

Size: 693 Bytes

Versions: 4

Compression:

Stored size: 693 Bytes

Contents

class User
  include ActiveModel::Serializers::JSON
  include ActiveModel::Serializers::Xml
  
  attr_accessor :login, :name, :groups

  def attributes
    {'login' => login, 'name' => name, 'groups' => groups.collect { |g| g.attributes } }
  end

  def initialize(attributes = {})
    @login = attributes['login']
    @name = attributes['name']
    @groups = (attributes['groups'] || []).collect {|g| Group.new g }
  end

  def self.authenticate(login, password)
    if login.size > 0 && password == "behappy"
      u = User.new
      u.login = login
      u.name = login.humanize
      u.groups = [Group.new('name' => login)]
      u
    end
  end
end
User.include_root_in_json = false
User

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
resty-generators-0.3.3 lib/generators/resty/setup/templates/user.rb
resty-generators-0.3.2 lib/generators/resty/setup/templates/user.rb
resty-generators-0.3.1 lib/generators/resty/setup/templates/user.rb
resty-generators-0.3.0 lib/generators/resty/setup/templates/user.rb