Module: AwesomePrint::LycraAttributes

Defined in:
lib/awesome_print/ext/lycra_attributes.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
# File 'lib/awesome_print/ext/lycra_attributes.rb', line 3

def self.included(base)
  base.send :alias_method, :cast_without_lycra_attributes, :cast
  base.send :alias_method, :cast, :cast_with_lycra_attributes
end

Instance Method Details

#awesome_lycra_attributes(object) ⇒ Object



19
20
21
# File 'lib/awesome_print/ext/lycra_attributes.rb', line 19

def awesome_lycra_attributes(object)
  Formatters::LycraAttributesFormatter.new(object, @inspector).format
end

#cast_with_lycra_attributes(object, type) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/awesome_print/ext/lycra_attributes.rb', line 8

def cast_with_lycra_attributes(object, type)
  cast = cast_without_lycra_attributes(object, type)
  return cast unless defined?(::Lycra::Attributes::Collection)

  if object.is_a?(::Lycra::Attributes::Collection)
    cast = :lycra_attributes
  end

  cast
end