Class: Adminterface::Extensions::Inputs::Base::Pluginish::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/adminterface/extensions/inputs/base/pluginish.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configs, options) ⇒ Config

Returns a new instance of Config.



9
10
11
12
13
# File 'lib/adminterface/extensions/inputs/base/pluginish.rb', line 9

def initialize(configs, options)
  @name = configs[:name]
  @configs = configs
  @options = options[@name.underscore.to_sym]
end

Instance Attribute Details

#configsObject (readonly)

Returns the value of attribute configs.



7
8
9
# File 'lib/adminterface/extensions/inputs/base/pluginish.rb', line 7

def configs
  @configs
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/adminterface/extensions/inputs/base/pluginish.rb', line 7

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/adminterface/extensions/inputs/base/pluginish.rb', line 7

def options
  @options
end

Instance Method Details

#attributesObject



15
16
17
18
19
# File 'lib/adminterface/extensions/inputs/base/pluginish.rb', line 15

def attributes
  return {} unless enabled?

  {"aa-#{name}": options.is_a?(Hash) ? options : defaults}
end

#defaultsObject



21
22
23
# File 'lib/adminterface/extensions/inputs/base/pluginish.rb', line 21

def defaults
  @defaults ||= configs[:options] || {}
end

#enabled?Boolean

Returns:

  • (Boolean)


25
26
27
28
# File 'lib/adminterface/extensions/inputs/base/pluginish.rb', line 25

def enabled?
  (!options.eql?(false) && configs[:default].eql?(true)) ||
    (options.present? || options.eql?(true))
end