class NCMB::Role
Public Class Methods
find_or_create(name)
click to toggle source
# File lib/ncmb/role.rb, line 18 def self.find_or_create(name) d = NCMB::DataStore.new('role') d.path = NCMB::Role.new(name).base_path role = d.where('roleName', name).limit(1).get.first role ? NCMB::Role.new(role.fields) : NCMB::Role.new(name).save() end
new(name)
click to toggle source
# File lib/ncmb/role.rb, line 7 def initialize(name) if name.is_a? Hash @fields = name else @fields = { roleName: name } end @fields[:acl] = NCMB::Acl.new end
Public Instance Methods
base_path()
click to toggle source
# File lib/ncmb/role.rb, line 29 def base_path path = "/#{@@client.api_version}/roles" end
name()
click to toggle source
# File lib/ncmb/role.rb, line 25 def name "role:#{@fields[:roleName]}" end