Custom attribute writer method checking allowed values (enum).
 @param [Object] scope Object to be assigned
435030
def scope=(scope)
      validator = EnumAttributeValidator.new('String', ["OTHER_TAX_SCOPE", "LINE_ITEM", "ORDER"])
      unless validator.valid?(scope)
        fail ArgumentError, "invalid value for 'scope', must be one of #{validator.allowable_values}."
      end
      @scope = scope
    end
175270
def selected_scopes(attribute)
      selected = object.send(attribute) || []
      selected = selected.values if selected.is_a?(Hash)
      selected = [selected] unless selected.is_a?(Array)
      selected = Decidim::Scope.where(id: selected.map(&:to_i)) unless selected.first.is_a?(Decidim::Scope)
      selected
    end
320529
private AttributesImpl validateScope(final Attributes atts, final AttributesImpl modified) {
        AttributesImpl res = modified;
        final String scope = atts.getValue(ATTRIBUTE_NAME_SCOPE);
        final URI href = toURI(atts.getValue(ATTRIBUTE_NAME_HREF));
        if (scope == null && href != null && href.isAbsolute()) {
            final boolean sameScheme = Objects.equals(currentFile.getScheme(), href.getScheme());
            final boolean sameAuthority = Objects.equals(currentFile.getRawAuthority(), href.getRawAuthority());
            if (!(sameScheme && sameAuthority)) {
                switch (processingMode) {
                    case LAX:
                        if (res == null) {
                            res = new AttributesImpl(atts);
                        }
                        addOrSetAttribute(res, ATTRIBUTE_NAME_SCOPE, ATTR_SCOPE_VALUE_EXTERNAL);
                        logger.warn(MessageUtils.getMessage("DOTJ075W", href.toString()).setLocation(locator).toString());
                        break;
                    default:
                        logger.warn(MessageUtils.getMessage("DOTJ076W", href.toString()).setLocation(locator) + ", using invalid value.");
                        break;
                }
            }
        }
        return res;
    }
169304
def is_in_scope(cls, want_scope: str, have_scopes: List[Scope]) -> bool:
        
        if not want_scope:
            return True
        if want_scope in have_scopes or want_scope.split(':')[0] in have_scopes:
            return True
        elif want_scope.startswith('read'):
            return cls.is_in_scope(want_scope.replace('read', 'write'), have_scopes)
        elif want_scope.startswith('write'):
            return cls.is_in_scope(want_scope.replace('write', 'admin'), have_scopes)
        else:
            return False
476833
def enum( definitions )
      super( definitions )
      definitions.each do |name, _|
        Helper.define_attr_i18n_method(self, name)
        Helper.define_collection_i18n_method(self, name)
      end
    end
1098341
public boolean scopeAllowed(String scope, String allowedScopes) {
        String[] allScopes = allowedScopes.split(SPACE);
        List<String> allowedList = Arrays.asList(allScopes);
        String[] scopes = scope.split(SPACE);
        int allowedCount = 0;
        for (String s : scopes) {
            if (allowedList.contains(s)) {
                allowedCount++;
            }
        }
        return (allowedCount == scopes.length);
    }
198803
def define_attr_writer(name, type)
      define_method("#{name}=") do |value|
        unless value.kind_of?(type)
          value = coerce(value, to: type)
          unless value.kind_of?(type)
            raise TypeError, "Attribute `#{name}` only accepts `#{type}` but got `#{value}`:`#{value.class}` instead"
          end
        end
        instance_variable_set("@#{name}", value)
      end
    end
661817
def write_attribute(name, value, options = {})
      if translated?(name)
        options = {:locale => nil}.merge(options)
        access = name.to_s
        unless attributes[access] == value || attribute_changed?(access)
          attribute_will_change! access
        end
        @translated_attributes[access] = value
        the_locale = options[:locale] || Mongoid::Globalize.locale
        self.translations.reject!{ |t| t.new_record? && t.locale != the_locale } if self.class.fallbacks_for_empty_translations
        globalize.write(the_locale, name, value)
      else
        super(name, value)
      end
    end
714209
def write_attr(attr_name, value, to_call = nil)
      self[attr_name] = value && to_call ? value.__send__(to_call) : value
    end
32575
def run
        raise Lupa::SearchAttributesError, "You need to specify search attributes." unless search_attributes

        search_attributes.each do |method_name, value|
          new_scope         = scope_class.public_send(method_name)
          scope_class.scope = new_scope unless new_scope.nil?
        end

        scope_class.scope
      end
719368
def input=(input)
      validator = EnumAttributeValidator.new('String', ["html", "xml", "auto"])
      unless validator.valid?(input)
        fail ArgumentError, "invalid value for 'input', must be one of #{validator.allowable_values}."
      end
      @input = input
    end
56700
function ENUM(values) {
    if (!values || !(values instanceof Array) || !values.length) {
        throw new Error();
    }
    if (!(this instanceof ENUM)) {
        return new ENUM(values);
    }
    this.sql = 'ENUM(' + values.join(',') + ')';
}
280914
def instance_writers
      _attrs.keys.map { |m| "#{m}=".to_sym }.select { |m| method_defined?(m) }
    end
767493
public void setScope(String scope) throws ApplicationException {
	scope = scope.toLowerCase().trim();

	if (scope.equals("server")) this.scope = SCOPE_SERVER;
	else if (scope.equals("application")) this.scope = SCOPE_APPLICATION;
	else if (scope.equals("session")) this.scope = SCOPE_SESSION;
	else if (scope.equals("request")) this.scope = SCOPE_REQUEST;
	else throw new ApplicationException("invalid value [" + scope + "] for attribute [scope] from tag [lock]", "valid values are [server,application,session]");
    }
390244
def validate_wrap(self, value):
        '''  '''
        self.item_type.validate_wrap(value)

        if value not in self.values:
            self._fail_validation(value, 'Value was not in the enum values')
699397
def isconst(cls, val):
        ''' 

        '''
        return isinstance(val, string_types) and \
               ((len(val) == 7 and val[0] == "#") or val in enums.NamedColor)
1289706
def define_accessors(option, value)
      setter = proc { |val|  set option, val, true }
      getter = proc { value }

      define_singleton_method("#{option}=", setter) if setter
      define_singleton_method(option, getter) if getter
    end