Class: NCMB::Role
Constant Summary
Constants included from NCMB
API_VERSION, DOMAIN, SCRIPT_API_VERSION, SCRIPT_DOMAIN
Class Method Summary collapse
Instance Method Summary collapse
- #base_path ⇒ Object
-
#initialize(name) ⇒ Role
constructor
A new instance of Role.
- #name ⇒ Object
Methods included from NCMB
Methods inherited from Object
#ClassName, #[], #call, #convert_params, #deletable?, #delete, #error, #fields, #method_missing, #path, #post, #put, #saved?, #set
Constructor Details
#initialize(name) ⇒ Role
Returns a new instance of Role.
7 8 9 10 11 12 13 14 15 16 |
# 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NCMB::Object
Class Method Details
.find_or_create(name) ⇒ Object
18 19 20 21 22 23 |
# 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 |