end of day commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
class Section
|
||||
include SimplyStored::Couch
|
||||
|
||||
property :title
|
||||
|
||||
property :path, type: Array, default: []
|
||||
|
||||
belongs_to :supplier
|
||||
has_many :tables
|
||||
|
||||
attr_protected :supplier_id
|
||||
|
||||
validates :supplier_id, presence: true
|
||||
|
||||
def width
|
||||
self.path.last.try(:first).to_f - self.path.first.try(:first).to_f
|
||||
end
|
||||
def height
|
||||
self.path.last.try(:last).to_f - self.path.first.try(:last).to_f
|
||||
end
|
||||
|
||||
def width=(val)
|
||||
val = val.to_f
|
||||
self.path[0] ||= [0.0, 0.0]
|
||||
self.path[1] ||= [0.0, 0.0]
|
||||
unless path[1][0] == val
|
||||
self.path[1][0] = val
|
||||
path_will_change!
|
||||
end
|
||||
end
|
||||
def height=(val)
|
||||
val = val.to_f
|
||||
self.path[0] ||= [0.0, 0.0]
|
||||
self.path[1] ||= [0.0, 0.0]
|
||||
unless path[1][1] == val
|
||||
self.path[1][1] = val
|
||||
path_will_change!
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user