Sha256: 47347a732c612a1720a4df538df048604d0936c0cb31607a6e1d809c336cda34
Contents?: true
Size: 677 Bytes
Versions: 5
Compression:
Stored size: 677 Bytes
Contents
class User include ActiveModel::Serializers::JSON 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 =~ /^oldstudent$|^dhammaworker$/ && 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
5 entries across 5 versions & 1 rubygems