Sha256: e11d206f434007e5273444165b8ee1f15397d422d7e5f708d18ea758925d9ac6

Contents?: true

Size: 678 Bytes

Versions: 3

Compression:

Stored size: 678 Bytes

Contents

module NCMB
  class Role < NCMB::Object
    include NCMB
    
    def initialize(name)
      if name.is_a? Hash
        @fields = name
      else
        @fields = {
          roleName: name
        }
      end
      @fields[:acl] = NCMB::Acl.new(@fields[:acl])
    end
    
    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
    
    def name
      "role:#{@fields[:roleName]}"
    end
    
    def base_path
      path = "/#{@@client.api_version}/roles"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ncmb-ruby-client-0.1.3 lib/ncmb/role.rb
ncmb-ruby-client-0.1.2 lib/ncmb/role.rb
ncmb-ruby-client-0.1.1 lib/ncmb/role.rb