Class: Jabara::ParseCom::Schema::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/jabara/parse_com/schema.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBuilder

Returns a new instance of Builder.



253
254
255
# File 'lib/jabara/parse_com/schema.rb', line 253

def initialize
  @schema = Schema.new
end

Instance Attribute Details

#schemaObject (readonly)

Returns the value of attribute schema.



237
238
239
# File 'lib/jabara/parse_com/schema.rb', line 237

def schema
  @schema
end

Class Method Details

.build(&block) ⇒ Object



239
240
241
242
243
# File 'lib/jabara/parse_com/schema.rb', line 239

def self.build(&block)
  this = self.new
  this.instance_eval(&block)
  return this.schema
end

.relation(object_type) ⇒ Object



245
246
247
248
249
250
251
# File 'lib/jabara/parse_com/schema.rb', line 245

def self.relation object_type
  self.build do
    type object_type
    key 'owningId',  string
    key 'relatedId', string
  end
end

Instance Method Details

#acl(user_acl_object_type:, role_acl_object_type:) ⇒ Object



320
321
322
# File 'lib/jabara/parse_com/schema.rb', line 320

def acl user_acl_object_type: ,role_acl_object_type:
  ACL.new(user_acl_object_type: user_acl_object_type, role_acl_object_type: role_acl_object_type)
end

#boolean(default: nil) ⇒ Object



316
317
318
# File 'lib/jabara/parse_com/schema.rb', line 316

def boolean default: nil
  Boolean.new default: default
end

#datetime(default: nil) ⇒ Object



304
305
306
# File 'lib/jabara/parse_com/schema.rb', line 304

def datetime default: nil
  DateTime.new default: default
end

#fileObject



300
301
302
# File 'lib/jabara/parse_com/schema.rb', line 300

def file
  File.new
end

#float(default: nil) ⇒ Object



292
293
294
# File 'lib/jabara/parse_com/schema.rb', line 292

def float default: nil
  Float.new default: default
end

#id(id_key_name) ⇒ Object



264
265
266
# File 'lib/jabara/parse_com/schema.rb', line 264

def id(id_key_name)
  @schema.id_key_name = id_key_name
end

#integer(default: nil) ⇒ Object



288
289
290
# File 'lib/jabara/parse_com/schema.rb', line 288

def integer default: nil
  Integer.new default: default
end

#json_stringObject



324
325
326
# File 'lib/jabara/parse_com/schema.rb', line 324

def json_string
  JSONString.new
end

#key(key_string, type) ⇒ Object

スキーマにキーを登録する

Raises:

  • (ArgumentError)


269
270
271
272
# File 'lib/jabara/parse_com/schema.rb', line 269

def key(key_string, type)
  raise ArgumentError, 'key_name must be string' unless key_string.is_a? ::String
  (@schema.key_defs)[key_string] = type
end

#parse_object_idObject



296
297
298
# File 'lib/jabara/parse_com/schema.rb', line 296

def parse_object_id
  ObjectId.new
end

#pointerObject



312
313
314
# File 'lib/jabara/parse_com/schema.rb', line 312

def pointer
  Pointer.new
end

#string(max: nil, default: nil) ⇒ Object



308
309
310
# File 'lib/jabara/parse_com/schema.rb', line 308

def string max: nil, default: nil
  String.new max: max, default: default
end

#timestampObject

TODO def array

Array.new

end



284
285
286
# File 'lib/jabara/parse_com/schema.rb', line 284

def timestamp
  TimeStamp.new
end

#type(object_type) ⇒ Object

オブジェクトのtype



260
261
262
# File 'lib/jabara/parse_com/schema.rb', line 260

def type(object_type)
  @schema.object_type = object_type
end

#variants(&block) ⇒ Object



328
329
330
# File 'lib/jabara/parse_com/schema.rb', line 328

def variants(&block)
  Variants.new(&block)
end