Class: Xpose::Exposed

Inherits:
Object
  • Object
show all
Defined in:
lib/xpose/exposed.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ Exposed

Returns a new instance of Exposed.



5
6
7
# File 'lib/xpose/exposed.rb', line 5

def initialize(**args)
  @conf = ::Xpose::Configuration.new(args)
end

Instance Attribute Details

#confObject

Returns the value of attribute conf.



3
4
5
# File 'lib/xpose/exposed.rb', line 3

def conf
  @conf
end

Instance Method Details

#decorated_value(instance) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/xpose/exposed.rb', line 14

def decorated_value(instance)
  @instance = instance
  @decorated_value ||=
    if value(instance) && conf.decorate
      ::Xpose::Decorated.new(conf.to_h).value(instance, value(instance))
    else
      nil
    end
end

#exposed_value(instance) ⇒ Object



24
25
26
# File 'lib/xpose/exposed.rb', line 24

def exposed_value(instance)
  decorated_value(instance) || value(instance)
end

#value(instance) ⇒ Object



9
10
11
12
# File 'lib/xpose/exposed.rb', line 9

def value(instance)
  @instance = instance
  @value ||= interpret_value
end