Class: Bulldog::Attachment::Maybe::StorableAttribute

Inherits:
Object
  • Object
show all
Defined in:
lib/bulldog/attachment/maybe.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#callbackObject

Returns the value of attribute callback.



266
267
268
# File 'lib/bulldog/attachment/maybe.rb', line 266

def callback
  @callback
end

#castObject 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

#memoizeObject 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

#nameObject

Returns the value of attribute name.



266
267
268
# File 'lib/bulldog/attachment/maybe.rb', line 266

def name
  @name
end

#per_styleObject 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(attachment, style_name)
  value =
    if callback.is_a?(Proc)
      callback.call(attachment)
    else
      if per_style?
        attachment.send(callback, style_name)
      else
        attachment.send(callback)
      end
    end
  value = attachment.send("serialize_#{name}", value) if cast
  value
end