Module: AwesomePrint::LycraAttribute

Defined in:
lib/awesome_print/ext/lycra_attribute.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_attribute.rb', line 3

def self.included(base)
  base.send :alias_method, :cast_without_lycra_attribute, :cast
  base.send :alias_method, :cast, :cast_with_lycra_attribute
end

Instance Method Details

#awesome_lycra_attribute(object) ⇒ Object



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

def awesome_lycra_attribute(object)
  Formatters::LycraAttributeFormatter.new(object, @inspector).format
end

#cast_with_lycra_attribute(object, type) ⇒ Object



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

def cast_with_lycra_attribute(object, type)
  cast = cast_without_lycra_attribute(object, type)
  return cast unless defined?(::Lycra::Attributes::Attribute)

  if object.is_a?(::Lycra::Attributes::Attribute)
    cast = :lycra_attribute
  end

  cast
end