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.
245 246 247 248 249 |
# File 'lib/bulldog/attachment/maybe.rb', line 245 def initialize(attributes) attributes.each do |name, value| send("#{name}=", value) end end |
Instance Attribute Details
#callback ⇒ Object
Returns the value of attribute callback.
266 267 268 |
# File 'lib/bulldog/attachment/maybe.rb', line 266 def callback @callback end |
#cast ⇒ Object Also known as: cast?
Returns the value of attribute cast.
266 267 268 |
# File 'lib/bulldog/attachment/maybe.rb', line 266 def cast @cast end |
#memoize ⇒ Object Also known as: memoize?
Returns the value of attribute memoize.
266 267 268 |
# File 'lib/bulldog/attachment/maybe.rb', line 266 def memoize @memoize end |
#name ⇒ Object
Returns the value of attribute name.
266 267 268 |
# File 'lib/bulldog/attachment/maybe.rb', line 266 def name @name end |
#per_style ⇒ Object Also known as: per_style?
Returns the value of attribute per_style.
266 267 268 |
# File 'lib/bulldog/attachment/maybe.rb', line 266 def per_style @per_style end |
Instance Method Details
#value_for(attachment, style_name) ⇒ Object
251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/bulldog/attachment/maybe.rb', line 251 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 |