Class: Netfira::WebConnect::Models::Image

Inherits:
Netfira::WebConnect::Model::Record::FileRecord show all
Defined in:
lib/netfira/web_connect/models/image.rb

Defined Under Namespace

Classes: FocusPoint

Constant Summary

Constants included from Netfira::WebConnect::Model::Record::Serializer

Netfira::WebConnect::Model::Record::Serializer::EXCLUDE_FROM_SERIALIZE

Instance Method Summary collapse

Methods inherited from Netfira::WebConnect::Model::Record::FileRecord

#<<, #attachment_file_name, #attachment_file_name=, #attachment_file_size, #attachment_file_size=, #checksum, #checksum=, #data, origin_key, table_name

Methods inherited from Netfira::WebConnect::Model::Record

#as_readonly, #as_readwrite, find_by_origin_id, find_or_create_by_origin_id, find_or_initialize_by_origin_id, has_file?, has_languages?, #origin_id, origin_key, related_classes, #reload, schema, sendable?, table_name, tree?, writable?, #write_with_type_casting

Methods included from Netfira::WebConnect::Model::Record::Materialization

#materialize

Methods included from Netfira::WebConnect::Model::Record::Digests

#digest

Methods included from Netfira::WebConnect::Model::Record::Serializer

#to_s

Methods included from Netfira::WebConnect::Model::Record::Relations

#relate, #unrelate

Methods inherited from Netfira::WebConnect::Model

#dispatch_event, plural_name, single_name, table_name

Instance Method Details

#data=(value) ⇒ Object



17
18
19
20
# File 'lib/netfira/web_connect/models/image.rb', line 17

def data=(value)
  super value
  self.width, self.height = FastImage.size(attachment.staged_path)
end

#dimensionsObject



22
23
24
# File 'lib/netfira/web_connect/models/image.rb', line 22

def dimensions
  [width, height]
end

#dimensions=(value) ⇒ Object



26
27
28
# File 'lib/netfira/web_connect/models/image.rb', line 26

def dimensions=(value)
  self.width, self.height = value
end

#focus_pointObject



13
14
15
# File 'lib/netfira/web_connect/models/image.rb', line 13

def focus_point
  @focus_point ||= FocusPoint.new(self)
end

#focus_point=(point) ⇒ Object



7
8
9
10
11
# File 'lib/netfira/web_connect/models/image.rb', line 7

def focus_point=(point)
  self.focus_point_top = point[:top]
  self.focus_point_left = point[:left]
  self.focus_point
end