glass-rails 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +60 -1
- data/lib/generators/glass/model/templates/model.rb +1 -1
- data/lib/glass/rails/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -119,7 +119,54 @@ timeline, you are registered to listen for notifications
|
|
119
119
|
that the user has acted on your card. You can specify a callback method
|
120
120
|
using the `has_menu_item` helper method, by passing in the
|
121
121
|
|
122
|
+
### Glass Models - Menu Item Callbacks
|
122
123
|
|
124
|
+
This framework does most of the heavy lifting for you for subscribing
|
125
|
+
to notifications to your timeline items. If a glass-user 'acts' on a menu-item
|
126
|
+
which you have specified on your card, you will generally be alerted of
|
127
|
+
that action (with the exception of a few built-in actions, like 'read-aloud').
|
128
|
+
|
129
|
+
You may want to perform actions when certain actions are performed. For
|
130
|
+
example, if you have an 'email me' menu-item defined, you may want to
|
131
|
+
perform a back-end task which emails some content to a glass-user.
|
132
|
+
|
133
|
+
The helper method `has_menu_item` therefore takes an options hash: if you specify
|
134
|
+
a key called "handles_with", then we will automatically invoke the value as an
|
135
|
+
instance method when the callback is triggered.
|
136
|
+
|
137
|
+
For example, in the code sample below:
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
class Glass::Tweet < Glass::TimelineItem
|
141
|
+
has_menu_item :email, handles_with: :respond_to_email_request
|
142
|
+
def respond_to_email_request
|
143
|
+
|
144
|
+
end
|
145
|
+
end
|
146
|
+
```
|
147
|
+
|
148
|
+
.. whenever you receive a notification from google that an "email" action has
|
149
|
+
been performed, the method "respond_to_email_request" will be automatically
|
150
|
+
executed for you.
|
151
|
+
|
152
|
+
For greater control over handling the callback from google, if you
|
153
|
+
define your callback method as accepting a parameter, then we will pass
|
154
|
+
the response hash from google into the callback method.
|
155
|
+
|
156
|
+
For instance:
|
157
|
+
|
158
|
+
```ruby
|
159
|
+
class Glass::Tweet < Glass::TimelineItem
|
160
|
+
has_menu_item :email, handles_with: :respond_to_email_request
|
161
|
+
def respond_to_email_request(response)
|
162
|
+
### we will pass the response object
|
163
|
+
### into the callback method, if you
|
164
|
+
### have allowed the callback
|
165
|
+
### to accept a parameter. This is done
|
166
|
+
### via a method arity check.
|
167
|
+
end
|
168
|
+
end
|
169
|
+
```
|
123
170
|
|
124
171
|
### Glass Models - (Posting Content)
|
125
172
|
|
@@ -160,9 +207,21 @@ mirror api for insertion into the timeline.
|
|
160
207
|
Then all you have to do is use the following command to actually insert the content:
|
161
208
|
|
162
209
|
```ruby
|
163
|
-
gt.
|
210
|
+
gt.insert()
|
164
211
|
```
|
165
212
|
|
213
|
+
Additionally, if you would like to merge in attributes into the hash before it is
|
214
|
+
posted to the mirror-api, then you can optionally pass in a hash of attributes
|
215
|
+
to the insert() method call, and the hash will be merged into the body_object that
|
216
|
+
is posted to the mirror api.
|
217
|
+
|
218
|
+
This last point is relevant, for example, in the case of reading aloud text.
|
219
|
+
To do so, you need to specify a speakableText: "some text to be read aloud" attribute
|
220
|
+
in the body object when it gets posted. You can therefore do something like this:
|
221
|
+
|
222
|
+
```ruby
|
223
|
+
gt.insert(speakableText: "some text to be read aloud")
|
224
|
+
```
|
166
225
|
|
167
226
|
## Contributing
|
168
227
|
|
@@ -16,7 +16,7 @@ class Glass::<%= model_name.camelize %> < Glass::TimelineItem
|
|
16
16
|
|
17
17
|
has_menu_item :custom_action_name, display_name: "this is displayed",
|
18
18
|
icon_url: "http://icons.iconarchive.com/icons/enhancedlabs/lha-objects/128/Filetype-URL-icon.png",
|
19
|
-
|
19
|
+
handles_with: :custom_action_handler
|
20
20
|
|
21
21
|
|
22
22
|
|
data/lib/glass/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glass-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-05-
|
13
|
+
date: 2013-05-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: railties
|