Class: AcmsRuby::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/acms_ruby/models/image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image_name, sort_no, base) ⇒ Image

Returns a new instance of Image.



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

def initialize(image_name, sort_no, base)
  @base = base
  @name = image_name
  @no = sort_no
  load_fields
end

Instance Attribute Details

#fieldsObject

Returns the value of attribute fields.



4
5
6
# File 'lib/acms_ruby/models/image.rb', line 4

def fields
  @fields
end

Instance Method Details

#field(key) ⇒ Object



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

def field(key)
  key = @name+'@'+key
  @fields.where(field_key: key).first
end

#load_fieldsObject



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

def load_fields
  @fields = @base.fields.where(field_sort: @no)
end

#val(key) ⇒ Object



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

def val(key)
  field(key).value
end