Class: ClassStubber::ActiveStorageAttachmentMultiple
- Inherits:
-
Object
- Object
- ClassStubber::ActiveStorageAttachmentMultiple
- Includes:
- Enumerable
- Defined in:
- lib/generators/rider_kick/templates/spec/support/class_stubber.rb
Overview
Multiple files attachment stub
Instance Attribute Summary collapse
-
#urls ⇒ Object
readonly
Returns the value of attribute urls.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #attached? ⇒ Boolean
- #blank? ⇒ Boolean
- #count ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #first ⇒ Object
-
#initialize(urls = []) ⇒ ActiveStorageAttachmentMultiple
constructor
A new instance of ActiveStorageAttachmentMultiple.
- #last ⇒ Object
- #length ⇒ Object
- #map(&block) ⇒ Object
- #present? ⇒ Boolean
- #size ⇒ Object
Constructor Details
#initialize(urls = []) ⇒ ActiveStorageAttachmentMultiple
Returns a new instance of ActiveStorageAttachmentMultiple.
95 96 97 98 |
# File 'lib/generators/rider_kick/templates/spec/support/class_stubber.rb', line 95 def initialize(urls = []) @urls = urls.compact @attachments = @urls.map { |url| ActiveStorageAttachmentSingle.new(url) } end |
Instance Attribute Details
#urls ⇒ Object (readonly)
Returns the value of attribute urls.
93 94 95 |
# File 'lib/generators/rider_kick/templates/spec/support/class_stubber.rb', line 93 def urls @urls end |
Instance Method Details
#[](index) ⇒ Object
144 145 146 |
# File 'lib/generators/rider_kick/templates/spec/support/class_stubber.rb', line 144 def [](index) @attachments[index] end |
#attached? ⇒ Boolean
100 101 102 |
# File 'lib/generators/rider_kick/templates/spec/support/class_stubber.rb', line 100 def attached? @urls.any? end |
#blank? ⇒ Boolean
104 105 106 |
# File 'lib/generators/rider_kick/templates/spec/support/class_stubber.rb', line 104 def blank? !attached? end |
#count ⇒ Object
124 125 126 |
# File 'lib/generators/rider_kick/templates/spec/support/class_stubber.rb', line 124 def count size end |
#each(&block) ⇒ Object
112 113 114 |
# File 'lib/generators/rider_kick/templates/spec/support/class_stubber.rb', line 112 def each(&block) @attachments.each(&block) end |
#empty? ⇒ Boolean
132 133 134 |
# File 'lib/generators/rider_kick/templates/spec/support/class_stubber.rb', line 132 def empty? @attachments.empty? end |
#first ⇒ Object
136 137 138 |
# File 'lib/generators/rider_kick/templates/spec/support/class_stubber.rb', line 136 def first @attachments.first end |
#last ⇒ Object
140 141 142 |
# File 'lib/generators/rider_kick/templates/spec/support/class_stubber.rb', line 140 def last @attachments.last end |
#length ⇒ Object
128 129 130 |
# File 'lib/generators/rider_kick/templates/spec/support/class_stubber.rb', line 128 def length size end |
#map(&block) ⇒ Object
116 117 118 |
# File 'lib/generators/rider_kick/templates/spec/support/class_stubber.rb', line 116 def map(&block) @attachments.map(&block) end |
#present? ⇒ Boolean
108 109 110 |
# File 'lib/generators/rider_kick/templates/spec/support/class_stubber.rb', line 108 def present? attached? end |
#size ⇒ Object
120 121 122 |
# File 'lib/generators/rider_kick/templates/spec/support/class_stubber.rb', line 120 def size @attachments.size end |