Class: MockupElement

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/mockup_element.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

Returns the value of attribute is_link



7
8
9
# File 'app/models/mockup_element.rb', line 7

def is_link
  @is_link
end

Instance Method Details

- (Object) attributes



12
13
14
# File 'app/models/mockup_element.rb', line 12

def attributes
  super.merge('is_link' => self.is_link)
end

- (Object) create_response_hash



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/models/mockup_element.rb', line 26

def create_response_hash
  response = {
      id: self.id,
      layer: self.layer,
      position: {x:self.position_x,y:self.position_y},
      width: self.element.width,
      height: self.element.height,
      name: self.name,
      is_link: self.is_link,
      mockup_url_id: self.mockup_url_id,
      mockup_id: self.mockup_id
  }
  response[:background_color] = self.element.background_color if self.element.background_color.present?
  response[:image] = self.element.image if self.element.image.present?
  response
end

- (Object) destroy_element



16
17
18
19
# File 'app/models/mockup_element.rb', line 16

def destroy_element
  element = self.element
  element.destroy if element.mockup_elements.size == 0
end