Class: Reactor::Cm::XmlAttribute

Inherits:
Object
  • Object
show all
Defined in:
lib/reactor/cm/xml_attribute.rb

Constant Summary collapse

AVAILABLE_SCOPES =
[:get, :set, :create]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, options) ⇒ XmlAttribute

Returns a new instance of XmlAttribute.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/reactor/cm/xml_attribute.rb', line 14

def initialize(name, type, options)
  @name = name
  @type = type.presence || :string

  @scopes =
  if options[:except].present?
    AVAILABLE_SCOPES - options[:except]
  elsif options[:only].present?
    options[:only]
  else
    AVAILABLE_SCOPES
  end
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/reactor/cm/xml_attribute.rb', line 10

def name
  @name
end

#scopesObject

Returns the value of attribute scopes.



12
13
14
# File 'lib/reactor/cm/xml_attribute.rb', line 12

def scopes
  @scopes
end

#typeObject

Returns the value of attribute type.



11
12
13
# File 'lib/reactor/cm/xml_attribute.rb', line 11

def type
  @type
end

Instance Method Details

#scope?(name) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/reactor/cm/xml_attribute.rb', line 28

def scope?(name)
  self.scopes.include?(name)
end