Skip to content

Commit afd9b64

Browse files
committed
Fixes typo and adds signature method.
1 parent 67e59b6 commit afd9b64

File tree

5 files changed

+74
-3
lines changed

5 files changed

+74
-3
lines changed

Changes.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## Parse-Stack Changelog
22

3+
### 1.6.8
4+
- NEW: Parse::Object#sig method to get quick information about an instance.
5+
- FIXES: Typo fix when using Array#objectIds.
6+
- Additional tests.
7+
38
### 1.6.7
49
- Default SERVER_URL changed to http://localhost:1337/parse
510
- NEW: Command line tool `parse-console` to do interactive Parse development with parse-stack.

LICENSE renamed to LICENSE.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
The MIT License (MIT)
2+
13
Copyright (c) 2014-2016 Anthony Persaud, Modernistik LLC
24

35
Permission is hereby granted, free of charge, to any person obtaining

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<img src='https://raw.githubusercontent.com/modernistik/parse-stack/master/.github/parse-ruby-sdk.png?raw=true' width='500' alt='Ruby Parse SDK'/>
22

3-
# Parse-Stack - The Parse Ruby Client SDK
3+
# Parse Stack - The Parse Ruby Client SDK
44

5-
Parse-Stack is the [Parse Server](https://github.com/ParsePlatform/parse-server) SDK, REST Client and ORM framework for [Ruby](https://www.ruby-lang.org/en/). It provides a client adapter, a query engine, an object relational mapper (ORM) and a Cloud Code Webhooks rack application.
5+
[Parse Stack](https://github.com/modernistik/parse-stack) is the [Parse Server](https://github.com/ParsePlatform/parse-server) SDK, REST Client and ORM framework for [Ruby](https://www.ruby-lang.org/en/). It provides a client adapter, a query engine, an object relational mapper (ORM) and a Cloud Code Webhooks rack application.
66

77
Below is a [quick start guide](https://github.com/modernistik/parse-stack#overview), but you can also check out the full [API Reference](http://www.rubydoc.info/github/modernistik/parse-stack) for more detailed information about our Parse Server SDK.
88

lib/parse/model/pointer.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ def parse_class
9393
@parse_class
9494
end
9595

96+
# @return [String] a string representing the class and id of this instance.
97+
def sig
98+
"#{@parse_class}##{id || 'new'}"
99+
end
100+
96101
# @return [Hash]
97102
def attributes
98103
ATTRIBUTES
@@ -185,7 +190,7 @@ class Array
185190
# This method maps all the ids (String) of all Parse::Objects in the array.
186191
# @return [Array<String>] an array of strings of ids.
187192
def objectIds
188-
map { |m| m.is_?(Parse::Pointer) ? m.id : nil }.compact
193+
map { |m| m.is_a?(Parse::Pointer) ? m.id : nil }.compact
189194
end
190195

191196
# Filter all objects in the array that do not inherit from Parse::Pointer or

test/lib/parse/models/pointer_test.rb

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
require_relative '../../../test_helper'
2+
3+
class TestPointer < Minitest::Test
4+
5+
def setup
6+
@id = 'theObjectId'
7+
@theClass = "_User"
8+
@pointer = Parse::Pointer.new(@theClass, @id)
9+
end
10+
11+
def test_base_fields
12+
pointer = @pointer
13+
assert_equal Parse::Model::TYPE_POINTER, 'Pointer'
14+
assert_respond_to pointer, :__type
15+
assert_equal pointer.__type, Parse::Model::TYPE_POINTER
16+
assert_respond_to pointer, :id
17+
assert_respond_to pointer, :objectId
18+
assert_equal pointer.id, @id
19+
assert_equal pointer.id, pointer.objectId
20+
21+
assert_respond_to pointer, :className
22+
assert_respond_to pointer, :parse_class
23+
assert_equal pointer.parse_class, @theClass
24+
assert_equal pointer.parse_class, pointer.className
25+
assert pointer.pointer?
26+
refute pointer.fetched?
27+
# Create a new pointer from this pointer. They should still be equal.
28+
assert pointer == pointer.pointer
29+
assert pointer.present?
30+
end
31+
32+
def test_json
33+
assert_equal @pointer.as_json, { :__type =>Parse::Model::TYPE_POINTER, className: @theClass, objectId: @id}
34+
end
35+
36+
def test_sig
37+
assert_equal @pointer.sig, "#{@theClass}##{@id}"
38+
end
39+
40+
def test_array_objectIds
41+
assert_equal [@pointer.id], [@pointer].objectIds
42+
assert_equal [@pointer.id], [@pointer,4, 'junk', nil].objectIds
43+
assert_equal [], [4, 'junk', nil].objectIds
44+
end
45+
46+
def test_array_valid_parse_objects
47+
assert_equal [@pointer], [@pointer].valid_parse_objects
48+
assert_equal [@pointer], [@pointer,4, 'junk', nil].valid_parse_objects
49+
assert_equal [], [4, 'junk', nil].valid_parse_objects
50+
end
51+
52+
def test_array_parse_pointers
53+
assert_equal [@pointer], [@pointer].parse_pointers
54+
assert_equal [@pointer, @pointer], [@pointer, {className: '_User', objectId: @id}].parse_pointers
55+
assert_equal [@pointer, @pointer], [@pointer, {'className' => '_User', 'objectId' => @id}].parse_pointers
56+
assert_equal [@pointer, @pointer], [nil, 4, "junk", {className: '_User', objectId: @id}, {'className' => '_User', 'objectId' => @id}].parse_pointers
57+
end
58+
59+
end

0 commit comments

Comments
 (0)