Class: InventosStreak::Field

Inherits:
Base
  • Object
show all
Defined in:
lib/inventos_streak/field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

all, #attributes, belongs_to, children, #destroy, #final_path, find, has_many, #initialize, parent, parents, #save, #set_variables

Constructor Details

This class inherits a constructor from InventosStreak::Base

Instance Attribute Details

#keyObject

Returns the value of attribute key.



2
3
4
# File 'lib/inventos_streak/field.rb', line 2

def key
  @key
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/inventos_streak/field.rb', line 2

def name
  @name
end

#typeObject

Returns the value of attribute type.



2
3
4
# File 'lib/inventos_streak/field.rb', line 2

def type
  @type
end

Instance Method Details

#add_tags(tags) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/inventos_streak/field.rb', line 6

def add_tags tags
  if self.type == "TAG"
    InventosStreak.post_json self.final_path, {
      tagSettings: {
        tags: tags.map do |tag|
          { tag: tag, added: true }
        end
      }
    }
  else
    raise ArgumentError.new("Cannot add tags to a field not of type 'TAG'")
  end
end