Class: GridCLI::Post::PostBase

Inherits:
BaseResource
  • Object
show all
Defined in:
lib/gridcli/resources/post.rb

Direct Known Subclasses

Dislike, Like, Message, Status

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseResource

#to_s

Class Method Details

.create(attributes) ⇒ Object

before we create, resolve names from subgrid and call hooks



6
7
8
9
10
11
12
# File 'lib/gridcli/resources/post.rb', line 6

def self.create(attributes)
  subgrids = SubGrids.new
  users = attributes[:recipients].split(",")
  attributes[:recipients] = subgrids.resolve(users).join(",")
  attributes = GridCLI.hooker.invoke :before_post_creation, attributes
  super attributes
end

Instance Method Details

#to_post_jsonObject

if we just call post.to_json, the root attribute will be “post” for prettyprint, the root attribute needs to be one of: like,dislike,status,message



16
17
18
19
# File 'lib/gridcli/resources/post.rb', line 16

def to_post_json
  type = self.class.name.split("::").last.downcase
  to_json(:root => type)
end