Class: Reactor::Cm::XmlAttribute

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

Constant Summary collapse

AVAILABLE_SCOPES =
%i(get set create).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, options) ⇒ XmlAttribute

Returns a new instance of XmlAttribute.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/reactor/cm/xml_attribute.rb', line 8

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.



6
7
8
# File 'lib/reactor/cm/xml_attribute.rb', line 6

def name
  @name
end

#scopesObject

Returns the value of attribute scopes.



6
7
8
# File 'lib/reactor/cm/xml_attribute.rb', line 6

def scopes
  @scopes
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/reactor/cm/xml_attribute.rb', line 6

def type
  @type
end

Instance Method Details

#scope?(name) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/reactor/cm/xml_attribute.rb', line 22

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