pupper 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pupper/model.rb +16 -1
- data/lib/pupper/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da1228421c6ae38ceac9673bba44acaec488541a
|
4
|
+
data.tar.gz: 80ca69cc2e867f6bea0d49c389e70ebd07df1200
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3bb052ba41f3ea2c7ec9f4e6d33e97fb764f39ef6c8d78645880a55038e62deba6fb4a23701cbdaea283401f111907e955531759423a2fbacb2b33b952b6966
|
7
|
+
data.tar.gz: 8fa6107e50e9083ea058a88e6c338514e237e13ca72cbd847b3d544f0380d2a78f8bb34353c94d636140c7b8bf2832cd2932d209ed1b174bffac05075c82cee9
|
data/lib/pupper/model.rb
CHANGED
@@ -40,18 +40,33 @@ module Pupper
|
|
40
40
|
class_methods do
|
41
41
|
attr_writer :primary_key, :backend, :static
|
42
42
|
|
43
|
+
# @overload primary_key=(identifier)
|
44
|
+
# Set the identifier the including model will use by default
|
45
|
+
# when finding or updating (defaults to `:uid`)
|
46
|
+
#
|
47
|
+
# == Parameters:
|
48
|
+
# identifier::
|
49
|
+
# A symbol refering to the identifying field in the model. e.g.
|
50
|
+
# `:id`.
|
43
51
|
def primary_key
|
44
52
|
@primary_key ||= :uid
|
45
53
|
end
|
46
54
|
|
55
|
+
# @overload static=(true_or_false)
|
56
|
+
# Declare whether or not the model has a corresponding API client or not.
|
57
|
+
# (default: `false`)
|
58
|
+
#
|
59
|
+
# == Parameters:
|
60
|
+
# true_or_false::
|
61
|
+
# `true` if the model has no API, `false` otherwise.
|
47
62
|
def static?
|
48
63
|
@static ||= false
|
49
64
|
end
|
50
65
|
|
51
66
|
def backend
|
67
|
+
return if static?
|
52
68
|
@backend ||= "#{model_name.name.pluralize}Client".constantize.new
|
53
69
|
rescue NameError
|
54
|
-
return unless static?
|
55
70
|
raise NoSuchBackend, <<-ERR
|
56
71
|
Model #{model_name.name} is looking for an API client that doesn't exist!
|
57
72
|
|
data/lib/pupper/version.rb
CHANGED