Class: GoogleFT::Table::Permission

Inherits:
Object
  • Object
show all
Defined in:
lib/google-ft/table/permission.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Permission

Returns a new instance of Permission.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/google-ft/table/permission.rb', line 5

def initialize(args)
  # Clean up args and make sure we were at least supplied the required ones.
  args = args.symbolize.delete_if {|k,v| ![:role, :type, :value, :require_link].include?(k)}
  raise ArgumentError unless args[:role] && args[:type] 

  # Set defaults.
  args[:value] ||= 'me'
  args[:require_link] ||= false

  # Set the attributes.
  self.role = args[:role]
  self.type = args[:type]
  self.value = args[:value]
  self.require_link = args[:require_link]
end

Instance Attribute Details

Returns the value of attribute require_link.



4
5
6
# File 'lib/google-ft/table/permission.rb', line 4

def require_link
  @require_link
end

#roleObject

Returns the value of attribute role.



4
5
6
# File 'lib/google-ft/table/permission.rb', line 4

def role
  @role
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/google-ft/table/permission.rb', line 4

def type
  @type
end

#valueObject

Returns the value of attribute value.



4
5
6
# File 'lib/google-ft/table/permission.rb', line 4

def value
  @value
end

Instance Method Details

#post_argsObject



21
22
23
24
25
26
27
28
29
# File 'lib/google-ft/table/permission.rb', line 21

def post_args
  # JSON formatted string for this permission.
  {
    :role => self.role,
    :type => self.type,
    :value => self.value,
    :withLink => self.require_link
  }.to_json
end