class AdequateSerialization::Attribute::Config

Attributes

attribute[R]
options[R]

Public Class Methods

new(attribute, options) click to toggle source
# File lib/adequate_serialization/attribute.rb, line 100
def initialize(attribute, options)
  @attribute = attribute
  @options = options
end

Public Instance Methods

to_attribute() click to toggle source
# File lib/adequate_serialization/attribute.rb, line 105
def to_attribute
  nested = nested_attribute_from(attribute, options)
  nested ? Config.new(nested, options).to_attribute : attribute
end

Private Instance Methods

if_option() click to toggle source
# File lib/adequate_serialization/attribute.rb, line 122
def if_option
  @if_option ||= options.delete(:if)
end
nested_attribute_from(attribute, options) click to toggle source
# File lib/adequate_serialization/attribute.rb, line 112
def nested_attribute_from(attribute, options)
  if options.delete(:optional)
    Optional.new(attribute)
  elsif if_option
    IfCondition.new(attribute, if_option)
  elsif unless_option
    UnlessCondition.new(attribute, unless_option)
  end
end
unless_option() click to toggle source
# File lib/adequate_serialization/attribute.rb, line 126
def unless_option
  @unless_option ||= options.delete(:unless)
end