Class: Bulldog::Attachment::Maybe::StorableAttribute
- Inherits:
-
Object
- Object
- Bulldog::Attachment::Maybe::StorableAttribute
- Defined in:
- lib/bulldog/attachment/maybe.rb
Instance Attribute Summary collapse
-
#callback ⇒ Object
Returns the value of attribute callback.
-
#cast ⇒ Object
(also: #cast?)
Returns the value of attribute cast.
-
#memoize ⇒ Object
(also: #memoize?)
Returns the value of attribute memoize.
-
#name ⇒ Object
Returns the value of attribute name.
-
#per_style ⇒ Object
(also: #per_style?)
Returns the value of attribute per_style.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ StorableAttribute
constructor
A new instance of StorableAttribute.
- #value_for(attachment, style_name) ⇒ Object
Constructor Details
#initialize(attributes) ⇒ StorableAttribute
Returns a new instance of StorableAttribute.
230 231 232 233 234 |
# File 'lib/bulldog/attachment/maybe.rb', line 230 def initialize(attributes) attributes.each do |name, value| send("#{name}=", value) end end |
Instance Attribute Details
#callback ⇒ Object
Returns the value of attribute callback.
251 252 253 |
# File 'lib/bulldog/attachment/maybe.rb', line 251 def callback @callback end |
#cast ⇒ Object Also known as: cast?
Returns the value of attribute cast.
251 252 253 |
# File 'lib/bulldog/attachment/maybe.rb', line 251 def cast @cast end |
#memoize ⇒ Object Also known as: memoize?
Returns the value of attribute memoize.
251 252 253 |
# File 'lib/bulldog/attachment/maybe.rb', line 251 def memoize @memoize end |
#name ⇒ Object
Returns the value of attribute name.
251 252 253 |
# File 'lib/bulldog/attachment/maybe.rb', line 251 def name @name end |
#per_style ⇒ Object Also known as: per_style?
Returns the value of attribute per_style.
251 252 253 |
# File 'lib/bulldog/attachment/maybe.rb', line 251 def per_style @per_style end |
Instance Method Details
#value_for(attachment, style_name) ⇒ Object
236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/bulldog/attachment/maybe.rb', line 236 def value_for(, style_name) value = if callback.is_a?(Proc) callback.call() else if per_style? .send(callback, style_name) else .send(callback) end end value = .send("serialize_#{name}", value) if cast value end |