Class: Avo::PhotoObject
- Inherits:
-
Object
- Object
- Avo::PhotoObject
- Defined in:
- lib/avo/photo_object.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(resource:) ⇒ PhotoObject
constructor
A new instance of PhotoObject.
- #options ⇒ Object
- #present? ⇒ Boolean
- #value ⇒ Object
- #visible_in_current_view? ⇒ Boolean
- #visible_on ⇒ Object
- #visible_on_edit? ⇒ Boolean
- #visible_on_index? ⇒ Boolean
- #visible_on_new? ⇒ Boolean
- #visible_on_show? ⇒ Boolean
Constructor Details
#initialize(resource:) ⇒ PhotoObject
Returns a new instance of PhotoObject.
4 5 6 |
# File 'lib/avo/photo_object.rb', line 4 def initialize(resource:) @resource = resource end |
Instance Method Details
#options ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/avo/photo_object.rb', line 11 def @options ||= if @resource.class&.send(key).present? @resource.class&.send(key) else {} end end |
#present? ⇒ Boolean
37 38 39 |
# File 'lib/avo/photo_object.rb', line 37 def present? value.present? end |
#value ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/avo/photo_object.rb', line 19 def value return unless .fetch(:source, nil).present? if [:source].is_a?(Symbol) record.send([:source]) elsif [:source].respond_to?(:call) Avo::ExecutionContext.new(target: [:source], record:, resource: @resource, view:).handle end end |
#visible_in_current_view? ⇒ Boolean
33 34 35 |
# File 'lib/avo/photo_object.rb', line 33 def visible_in_current_view? send(:"visible_on_#{view}?") end |
#visible_on ⇒ Object
29 30 31 |
# File 'lib/avo/photo_object.rb', line 29 def visible_on @visible_on ||= Array.wrap([:visible_on] || [:show, :forms]) end |
#visible_on_edit? ⇒ Boolean
45 |
# File 'lib/avo/photo_object.rb', line 45 def visible_on_edit? = visible_in_either?(:edit, :forms) |
#visible_on_index? ⇒ Boolean
41 |
# File 'lib/avo/photo_object.rb', line 41 def visible_on_index? = visible_in_either?(:index, :display) |
#visible_on_new? ⇒ Boolean
47 |
# File 'lib/avo/photo_object.rb', line 47 def visible_on_new? = visible_in_either?(:new, :forms) |
#visible_on_show? ⇒ Boolean
43 |
# File 'lib/avo/photo_object.rb', line 43 def visible_on_show? = visible_in_either?(:show, :display) |