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.



235
236
237
# File 'lib/jabara/parse_com/schema.rb', line 235

def initialize
  @schema = Schema.new
end

Instance Attribute Details

#schema(&block) ⇒ Object (readonly)

Returns the value of attribute schema.



219
220
221
# File 'lib/jabara/parse_com/schema.rb', line 219

def schema
  @schema
end

Class Method Details

.build(&block) ⇒ Object



221
222
223
224
225
# File 'lib/jabara/parse_com/schema.rb', line 221

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

.relation(object_type) ⇒ Object



227
228
229
230
231
232
233
# File 'lib/jabara/parse_com/schema.rb', line 227

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



306
307
308
# File 'lib/jabara/parse_com/schema.rb', line 306

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



302
303
304
# File 'lib/jabara/parse_com/schema.rb', line 302

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

#datetime(default: nil) ⇒ Object



290
291
292
# File 'lib/jabara/parse_com/schema.rb', line 290

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

#fileObject



286
287
288
# File 'lib/jabara/parse_com/schema.rb', line 286

def file
  File.new
end

#float(default: nil) ⇒ Object



278
279
280
# File 'lib/jabara/parse_com/schema.rb', line 278

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

#id(id_key_name) ⇒ Object



246
247
248
# File 'lib/jabara/parse_com/schema.rb', line 246

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

#integer(default: nil) ⇒ Object



274
275
276
# File 'lib/jabara/parse_com/schema.rb', line 274

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

#json_stringObject



310
311
312
# File 'lib/jabara/parse_com/schema.rb', line 310

def json_string
  JSONString.new
end

#key(key_string, type) ⇒ Object

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

Raises:

  • (ArgumentError)


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

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



282
283
284
# File 'lib/jabara/parse_com/schema.rb', line 282

def parse_object_id
  ObjectId.new
end

#pointerObject



298
299
300
# File 'lib/jabara/parse_com/schema.rb', line 298

def pointer
  Pointer.new
end

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



294
295
296
# File 'lib/jabara/parse_com/schema.rb', line 294

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

#timestampObject

TODO def array

Array.new

end



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

def timestamp
  TimeStamp.new
end

#type(object_type) ⇒ Object

オブジェクトのtype



242
243
244
# File 'lib/jabara/parse_com/schema.rb', line 242

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

#variants(&block) ⇒ Object



314
315
316
# File 'lib/jabara/parse_com/schema.rb', line 314

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